0

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?

6
  • 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, 2013 at 14:44
  • 1
    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. Dec 6, 2013 at 14:45
  • @DanBig: I don't mind the reboot taking 35 seconds, I do mind the need to reboot.
    – sharptooth
    Dec 6, 2013 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, 2013 at 14:59
  • @sharptooth Windows have to be rebooted when you change the computer name.
    – pauska
    Dec 6, 2013 at 14:59

2 Answers 2

7

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.

0

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

Source: http://timnew.github.io/blog/2012/04/13/powershell-script-to-rename-computer-without-reboot/

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

2
  • 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, 2013 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, 2013 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .