Invoke-VMShutdown -force

Jun 18, 2010 at 1:06 PM

Tell me please, this script correctly ? or may be simply ?

 

$st1=Get-VMState -VM pp10 -Server pp-hv03 | fl Enabledstate

if ($st1 = "EnabledState : Running")

 { Invoke-VMShutdown -VM pp10 -Server pp-hv03 -force -shutdowntimeout 10 }

elseIf ($st1 = "EnabledState : Stopped")
 {
  copy-item \\pp-hv03\E$\vms\pp10\sql_c.vhd -destination D:\
 
  Set-Vmstate -VM pp10 -Server pp-hv03 -state "Running"
 }

Aug 10, 2010 at 9:29 AM

The Force Parameter is an boolean, so you have to typ true after -force

correct is: 

Invoke-VMShutdown -VM pp10 -Server pp-hv03 -force ture -shutdowntimeout 10

 

regards

Matthias

Dec 28, 2010 at 11:27 AM

PS C:\execute\vms> Invoke-VMShutdown -VM pp10 -Server pp-hv03 -force true
Invoke-VMShutdown : Could not begin Shutdown of pp10
строка:1 знак:18
+ Invoke-VMShutdown <<<<  -VM pp10 -Server pp-hv03 -force true
    + CategoryInfo          : InvalidResult: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : 32780,Invoke-VMShutdown

PS C:\execute\vms> Invoke-VMShutdown -VM pp10 -Server pp-hv03 -force true -shutdowntimeout 10
Invoke-VMShutdown : Could not begin Shutdown of pp10
строка:1 знак:18
+ Invoke-VMShutdown <<<<  -VM pp10 -Server pp-hv03 -force true -shutdowntimeout 10
    + CategoryInfo          : InvalidResult: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : 32780,Invoke-VMShutdown

Coordinator
Feb 4, 2011 at 11:49 AM
Edited Feb 4, 2011 at 11:51 AM

This is usually caused when the VM doesn't have the integration components,

But powershell should catch the error I'll have a look at this one.

Oh, and  force is a switch. You can do -Force:$true or just -Force.  not sure  this syntax will cause a problem