Powershell command to save a Hyper-V Guest state to disk
Does anybody know the command to save the st开发者_高级运维ate of a hyper-v guest-os from powershell?
Ex)
Save-VM GuestName ?
Take a look at http://pshyperv.codeplex.com The PowerShell module there for Hyper-V management has the cmdlets for working with virtual machines.
In the above module, for discovering and manipulating Machine states:
Get-VMState
Set-VMState
Convert-VmState
Ping-VM
Test-VMHeartBeat
Shutdown-VM
Start-VM
Stop-VM
Suspend-VM
So, to answer your question, to save VM state, the cmdlet will be Set-VMState
If you don't want to use any module and write your own function using WMI, take a look at MSDN documentation for Hyper-V WMI interfaces.
http://msdn.microsoft.com/en-us/library/cc723874(v=VS.85).aspx
Ravikanth's answer looks complicated and takes a lot of reading.. but this works for me:
Stop-VM -name vmName
Or type: Get-VM | Stop-VM -save
to put all machines in a saved state.
精彩评论