Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
远程PowerShell脚本不支持';无法应用Hyper-V快照_Powershell_Windows Server 2008_Hyper V - Fatal编程技术网

远程PowerShell脚本不支持';无法应用Hyper-V快照

远程PowerShell脚本不支持';无法应用Hyper-V快照,powershell,windows-server-2008,hyper-v,Powershell,Windows Server 2008,Hyper V,我正在尝试通过PowerShell远程应用Hyper-V快照。我会关注这个 顺便说一下,我在Server2008R2 简言之: 连接到远程服务器: $password = ConvertTo-SecureString "password" -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential ("domain\user", $password) Enter-PSSession -Compu

我正在尝试通过PowerShell远程应用Hyper-V快照。我会关注这个

顺便说一下,我在Server2008R2

简言之:

连接到远程服务器:

$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("domain\user", $password)
Enter-PSSession -Computer computerName -Credential $cred
这个很好用。我已经通过在机器上创建一个文件夹来测试这个远程连接

应用快照:

$HyperVServer = Read-Host "Specify the Hyper-V Server to use (enter '.' for the local computer)"

# Prompt for the virtual machine to use
$VMName = Read-Host "Specify the name of the virtual machine"

# Prompt for the name of the snapshot to apply
$SnapshotName = Read-Host "Specify the name of the snapshot to apply"

# Get the management service
$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer

# Get the virtual machine object
$VM = gwmi MSVM_ComputerSystem -filter "ElementName='$VMName'" -namespace "root\virtualization" -computername $HyperVServer

# Find the snapshot that we want to apply
$Snapshot = gwmi -Namespace root\virtualization -Query "Associators Of {$VM} Where AssocClass=Msvm_ElementSettingData ResultClass=Msvm_VirtualSystemSettingData" | where {$_.ElementName -eq $SnapshotName} | select -first 1

# Apply the snapshot
$VMMS.ApplyVirtualSystemSnapshot($VM, $Snapshot)
我一个接一个地执行这些命令,它会发现VM和快照很好,但是当我执行最后一个命令时,我的快照不会被应用。它也不会失败,没有错误消息

但是,在执行最后一个命令后,我确实得到了以下结果:

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     : 
__DYNASTY        : __PARAMETERS
__RELPATH        : 
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         : 
__NAMESPACE      : 
__PATH           : 
ReturnValue      : 32775
此返回值根据指示指示此操作(32775)的
无效状态。这是什么意思?如何修复此问题以实际应用快照

虚拟机当前处于运行状态,因此我再次尝试关闭虚拟机并正确应用快照


如何强制快照在VM处于运行状态时应用?

这篇文章明确指出:

需要注意的一点是,如果您尝试应用快照时虚拟机正在运行,则此操作将失败–需要先关闭虚拟机或将其置于已保存状态


ApplyVirtualSystemSnapshot
无法远程运行VM

您是否尝试过通过Hyper-V UI“手动”拍摄快照?“此操作的无效状态”似乎是指它所说的-例如,我见过在合并过程中发生这种情况(但在您的情况下不会发生这种情况)。@Al Muhandis拍摄快照没有问题,这篇文章与拍摄快照无关。问题是在VM处于运行状态时通过PowerShell应用快照。是的,很抱歉应用它。你试过通过UI应用它吗?@Al-Muhandis是的,我可以在VM处于运行状态时手动应用快照,没有问题。当我尝试通过WMI/PowerShell执行相同操作时,我仅获得此操作的
无效状态