Script to change hostname

Reyesrj
Reyesrj used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

Commented:
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.

Author

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
Distinguished Expert 2017
Commented:
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
https://technet.microsoft.com/en-us/library/hh849792%28v=wps.620%29.aspx though it depends on which powershell version your image includes.

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

https://msdn.microsoft.com/en-us/library/aa393056%28v=vs.85%29.aspx

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.

Author

Commented:
thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial