Get-VMSnapshot Doesn't work in Enter-PSsession script
hello,
i have encountered issue writing small script.
for reason works if run line line, if run whole script fails.
this error get:
get-vmsnapshot : term 'get-vmsnapshot' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again.@ line:3 char:30
+ invoke-command -scriptblock {get-vmsnapshot –vmname "pc000006_uat" -name "pc0000 ...
+ ~~~~~~~~~~~~~~
+ categoryinfo : objectnotfound: (get-vmsnapshot:string) [], commandnotfoundexception
+ fullyqualifiederrorid : commandnotfoundexception
and script:
thank helpenter-pssession -computername "$machine_name"
invoke-command -scriptblock
{get-vmsnapshot –vmname "pc000006_uat" -name "pc000006_uat backup" sort-object creationtime -descending |
select-object -first 1 |
restore-vmsnapshot -confirm:$false -erroraction stop }
exit-pssession
this:
enter-pssession -computername "$machine_name" get-vmsnapshot –vmname "pc000006_uat" -name "pc000006_uat backup" | sort-object creationtime -descending | select-object -first 1 | restore-vmsnapshot -confirm:$false exit-pssession
or this:
invoke-command -computername $machine_name -scriptblock { get-vmsnapshot –vmname pc000006_uat -name "pc000006_uat backup" | sort-object creationtime -descending | select-object -first 1 | restore-vmsnapshot -confirm:$false -erroraction stop }cannot mix two.
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment