Problem Executing Move-VM (Hyper-V Cmdlet) Remotely
i working on modifying shared nothing live migration ps script can found here: http://blogs.inframon.com/post/2014/03/21/scripting-shared-nothing-live-migration.aspx allow script ran windows 8/server 2012 machine granted hyper-v/failover cluster modules installed , imported. right now, script has run source vm(s) server due usage of move-vm cmdlet. i struggling executing move-vm cmdlet remotely , have spent 3-4 hours troubleshooting this. i've tried several different things including invoke-command, invoke-command w/ ps session, etc, etc. i keep running 2 same errors every time no matter do. i have posted examples below along ps error output. any appreciated.
assume following variables defined correctly:
$sourceserver
$credential
$updatedvmreport
use variation of first example shown below trying retrieve total time taken live migrate vm(s).
example 1:
$scripttoexecute = { move-vm -compatibilityreport $updatedvmreport } $timetakentomove = measure-command -expression { invoke-command -computername $sourceserver -credential $credential -scriptblock $scripttoexecute } cannot bind argument parameter 'compatibilityreport' because null. + categoryinfo : invaliddata: (:) [move-vm], parameterbindingvalidationexception + fullyqualifiederrorid : parameterargumentvalidationerrornullnotallowed,microsoft.hyperv.powershell.commands.movevmcommand + pscomputername : bg-hq-hyperv1
example 2:
$serversession = new-pssession -computername $sourceserver -credential $credential $timetakentomove = measure-command -expression { invoke-command -session $serversession -scriptblock { move-vm -compatibilityreport $updatedvmreport } } cannot bind argument parameter 'compatibilityreport' because null. + categoryinfo : invaliddata: (:) [move-vm], parameterbindingvalidationexception + fullyqualifiederrorid : parameterargumentvalidationerrornullnotallowed,microsoft.hyperv.powershell.commands.movevmcommand + pscomputername : bg-hq-hyperv3
example 3:
invoke-command -computername $sourceserver -credential $credential -scriptblock { move-vm -compatibilityreport $updatedvmreport } cannot bind argument parameter 'compatibilityreport' because null. + categoryinfo : invaliddata: (:) [move-vm], parameterbindingvalidationexception + fullyqualifiederrorid : parameterargumentvalidationerrornullnotallowed,microsoft.hyperv.powershell.commands.movevmcommand + pscomputername : bg-hq-hyperv3
everytime check $updatedvmreport see if contains data, , outputs following:
ps c:\windows\system32> $updatedvmreport vm : microsoft.hyperv.powershell.virtualmachine operationtype : movevirtualmachineandstorage destination : qa-host14 path : snapshotpath : vhddestinationpath : vhdsourcepath : incompatibilities :
the other error running regarding deserialization caused running move-vm cmdlet remotely w/ compatibilityreport parameter:
example 4:
$scripttoexecute = { param($vmreporttouse) move-vm -compatibilityreport $vmreporttouse } invoke-command -session $serversession -scriptblock $scripttoexecute -argumentlist $updatedvmreport cannot bind parameter 'compatibilityreport'. cannot convert "microsoft.hyperv.powershell.vmcompatibilityreport" value of type "deserialized.microsoft.hyperv.powershell.vmcompatibilityreport" type "microsoft.hyperv.powershell.vmcompatibilityreport". + categoryinfo : invalidargument: (:) [move-vm], parameterbindingexception + fullyqualifiederrorid : cannotconvertargumentnomessage,microsoft.hyperv.powershell.commands.movevmcommand + pscomputername : bg-hq-hyperv3, help.
a.j.
$updatevmreport contain data, when it's on computer, not when it's on remote computer. start trying using scope modifier value stored in $updatevmreport remote computer. here's example based on example 3.
invoke-command -computername $sourceserver -credential $credential -scriptblock { move-vm -compatibilityreport $using:updatedvmreport }
if doesn't work - , won't if you're using ps 2.0 or less - there's other options of getting local, variable's value remote computer.
here's more using scope modifier:
"the using scope modifier
using special scope modifier identifies local
variable in remote command. default, variables in remote
commands assumed defined in remote session.
using scope modifier introduced in windows powershell 3.0.
more information, see about_remote_variables."
from: http://technet.microsoft.com/en-us/library/hh847849.aspx , get-help about_scopes. if read 1 of these, @ both part i've quoted above , example it's used.
Windows Server > Windows PowerShell
Comments
Post a Comment