Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's what I see in a typical "system" log of Azure role instances for their initialization sequence (this is for Windows Server 2008 R2, I haven't checked other versions):

  • the VM is turned on,
  • the VM computer name is changed
  • the VM is rebooted

This is done because the computer name specified initially will not suit for a dynamically configured network, so a suitable name is generated and VM is assigned that name. Since changing a powered on machine name generally requires a reboot the VM is then rebooted.

The problem is this takes extra 35 seconds and this time is effectively wasted.

So there's a powered on Hyper-V VM and its "computer name" needs to be changed.

How can this be done without turning the VM on?

share|improve this question
Are you asking how to change a windows hostname while it is powered off? And actually complaining about a 35 second reboot? – DanBig Dec 6 '13 at 14:44
If you're asking how to change the Windows hostname while it's powered off the answer is - you can't. Windows requires you to boot the machine, rename and reboot. It's the same in all versions of Windows. – cole Dec 6 '13 at 14:45
@DanBig: I don't mind the reboot taking 35 seconds, I do mind the need to reboot. – sharptooth Dec 6 '13 at 14:48
What does this statement mean: "This is done because the computer name specified initially will not suit for a dynamically configured network"? Also, just to clarify, are you referring to the Windows computer name or the Virtual Machine name? – joeqwerty Dec 6 '13 at 14:59
@sharptooth Windows have to be rebooted when you change the computer name. – pauska Dec 6 '13 at 14:59
up vote 7 down vote accepted

It is impossible to change any Windows hostname while the machine is powered off, virtual or not. A reboot is also required after a hostname change for it to take effect.

share|improve this answer

It is possible to change computer name without a reboot. I am successful on windows 7 (virtual) machines with this powershell script:

$ComputerName = "New Name"

Remove-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -   name "Hostname" 
Remove-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "NV Hostname" 

New-PSDrive -name HKU -PSProvider "Registry" -Root "HKEY_USERS"

Set-ItemProperty -path  "HKLM:\SYSTEM\CurrentControlSet\Control\Computername\Computername" -name "Computername" - value $ComputerName
Set-ItemProperty -path   "HKLM:\SYSTEM\CurrentControlSet\Control\Computername\ActiveComputername" -name    "Computername" -value $ComputerName
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name  "Hostname" -value $ComputerName
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name  "NV Hostname" -value  $ComputerName
Set-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" - name "AltDefaultDomainName" -value $ComputerName
Set-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -name "DefaultDomainName" -value $ComputerName
#Set-ItemProperty -path "HKU:\.Default\Software\Microsoft\Windows Media\WMSDK\General" - name "Computername" -value $ComputerName


You need to check it and see if it works for you.

share|improve this answer
That article says its a hack, and may not be a complete solution. And may have unknown potential issues. The complete solution, is to just reboot the thing. So, take the hack for what it is. – DanBig Dec 9 '13 at 12:59
We have 300 hundred nodes running that hack in production. So, yes it's a hack and it works but it depends on what you want to achieve. And you are right that to change hostname the restart can't be skipped. For us, the computer name counts more than a hostname. – piotrektt Dec 9 '13 at 18:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.