Wednesday, 24 April 2013

Export Hyper-V Virtual Machine to a File Share in a Workgroup

I have a number of Windows Server 2012 Hyper-V hosts that are not members of a Domain.
To export the Virtual Machines to a File Server we need to authenticate the System service account to the File Server before the Hyper-V Management Service can access the shares. I found this neat trick on Microsoft's Technet Forum which worked wonderfully using PSExec;

1. Open an elevated command prompt: Click start, type CMD, and press Ctrl+Shift+Enter, then accept the UAC dialog (if applicable).

2. Run:
 psexec.exe \\<localServerName> /s cmd.exe
 This will provide you with a new command prompt, but it will instead run under the SYSTEM context, instead of your user context.

3. Run:
 net use \\<remoteServerName>\<sharename> /user:<domain>\<userName> <password>
 This authenticates the SYSTEM account to the share you want to export to.  
 As an example, the line could look like: "net use \\server2\c$ /user:mydomain\Administrator MyAw3s0m3Pwd"

4. Return to the Hyper-V MMC, and try your export again.  It should work now.

5. When you're done, use:
 net use \\<remoteServerName>\<sharename> /delete
 This revokes the credentials from the SYSTEM account.  Alternatively, you could reboot.

6. Type exit, press enter.  You've dropped back to the original command prompt.  Type exit and press enter again, or simply close the window.

This is not a process you would want to perform for a nightly backup, but as a once off it does the trick.