windows server 2008 - Remote PowerShell script doesn't apply Hyper-V Snapshot -


i'm attempting remotely apply hyper-v snapshot through powershell. i'm following ben armstrong's guide this.

i'm in server 2008 r2, way.

in nutshell:

connecting remote server:

$password = convertto-securestring "password" -asplaintext -force $cred = new-object system.management.automation.pscredential ("domain\user", $password) enter-pssession -computer computername -credential $cred 

this works fine. i've tested remote connection creating folder on machine.

applying snapshot:

$hypervserver = read-host "specify hyper-v server use (enter '.' local computer)"  # prompt virtual machine use $vmname = read-host "specify name of virtual machine"  # prompt name of snapshot apply $snapshotname = read-host "specify name of snapshot apply"  # management service $vmms = gwmi -namespace root\virtualization msvm_virtualsystemmanagementservice -computername $hypervserver  # virtual machine object $vm = gwmi msvm_computersystem -filter "elementname='$vmname'" -namespace "root\virtualization" -computername $hypervserver  # find snapshot want apply $snapshot = gwmi -namespace root\virtualization -query "associators of {$vm} assocclass=msvm_elementsettingdata resultclass=msvm_virtualsystemsettingdata" | {$_.elementname -eq $snapshotname} | select -first 1  # apply snapshot $vmms.applyvirtualsystemsnapshot($vm, $snapshot) 

i execute these one-by-one, it's finding vm , snapshot fine, when execute final command, snapshot not applied. doesn't fail either, no error message.

i following, however, after executing final command:

__genus          : 2 __class          : __parameters __superclass     :  __dynasty        : __parameters __relpath        :  __property_count : 1 __derivation     : {} __server         :  __namespace      :  __path           :  returnvalue      : 32775 

this return value indicates invalid state operation (32775) according this msdn page. mean? how fix apply snapshot?

the vm in running state, tried again vm shut down , snapshot applied properly.

how can force snapshot apply vm in running state?

the article states that:

one thing aware of operation fail if virtual machine running when try apply snapshot – virtual machine needs turned off or put saved state first.

applyvirtualsystemsnapshot doesn't work remotely running vm's


Comments

Popular posts from this blog

Need help in packaging app using TideSDK on Windows -

java - Why does my date parsing return a weird date? -

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -