23 lines
512 B
PowerShell
Executable File
23 lines
512 B
PowerShell
Executable File
#!/usr/bin/env pwsh
|
|
|
|
. /opt/idssys/powerwall/settings.ps1
|
|
|
|
Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
|
|
|
|
Get-Datastore | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} | Get-VM | if ($_.PowerState -eq "PoweredOn") {
|
|
Try{
|
|
$vm = Get-VM -Name $vmName -ErrorAction Stop
|
|
switch($vm.PowerState){
|
|
'poweredon' {
|
|
sleep 5
|
|
}
|
|
}
|
|
}
|
|
Catch{
|
|
Write-Host "VM '$($vmName)' not found!"
|
|
}
|
|
}
|
|
|
|
exit 0
|
|
|