Functions/Stop-AllVms.ps1
function Stop-AllVms { [CmdletBinding()] param ( [Parameter()] [switch] $DoNotStopGateway ) Get-VM | Where-Object Name -NE "JT-Gateway2" | Stop-VM -AsJob -Force -Verbose if(!($DoNotStopGateway)) { Start-Job -ScriptBlock {start-sleep 10; Get-VM "JT-Gateway2" | Stop-VM -Verbose} } Get-Process vmconnect -ea 0 | Stop-Process } |