Script to change hostname

Hi All,

I would like to know if it’s possible and how to create a script to change a computer hostname.  Our techs will create a master image and copy the image to about 20 workstations.  If I had all the MAC addresses of all twenty workstations (I’ll get from DHCP) I want the script to assign a specific hostname to that workstation if it has that MAC address.  So the script will be imaged to all 20 workstations.  When imaging is completed all that will be needed is to run the script.

Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What OS are you dealing with?
Usually, if you have the mac and names, you can do the post install script using depending on your answer to the first question.
ReyesrjAuthor Commented:
Windows 7 OS.  I also plan or having the script run on the first reboot.  Again if this is possible.

Thanks for the reply
it is, is your image pre-AD.
there are several ways the hostname can be set using powershell
as well as join the system into the domain, etc.
rename-computer though it depends on which powershell version your image includes.

WMI using Vb can be extended/used using powershell with wmi tie in

Instead of doing it one at a time, decide what you want done to the system upon deployment of the OS and how you are planing on to include the info in the image or push a script/data after the image is deployed as an addon file/data.

DHCP could pose an issue with name conflict on network unless your reference to DHCP will deal with IP reservation based on the MAC address.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ReyesrjAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.