简体   繁体   中英

Powershell command to save a Hyper-V Guest state to disk

Does anybody know the command to save the state 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 Get-VM | Stop-VM -save to put all machines in a saved state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM