This is an old revision of the document!
wmic computersystem where caption='currentname' rename 'newname'
netdom renamecomputer %COMPUTERNAME% /Newname "NEW-NAME"
Windows 2008/2012:
netdom renamecomputer "$env:COMPUTERNAME" /Newname "NEW-NAME"
Then reboot to activate the new hostname:
shutdown -r -t 0
WHS script:
Set objWMIService = GetObject("Winmgmts:root\cimv2") For Each objComputer in _ objWMIService.InstancesOf("Win32_ComputerSystem") objComputer.rename "NewComputerName", NULL, NULL Next