This commit is contained in:
2023-12-13 09:29:51 -06:00
parent dd9b2fb35b
commit e55ae20a29
4 changed files with 31 additions and 45 deletions

View File

@@ -1,22 +1,17 @@
#!/usr/bin/env pwsh
# Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
. /opt/idssys/powerwall/settings.ps1
Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
$ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
Get-Datastore | Where {$_.Name -like '*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!"
}
$VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-*'} | Get-VM
Foreach ($VM in $VMLIST) {
while((Get-VM $VM).PowerState -ne 'PoweredOff') {
write-host waiting
Start-Sleep -Seconds 1
}
}
exit 0
Disconnect-VIServer $ESXI -Confirm:$false

View File

@@ -1,21 +1,17 @@
#!/usr/bin/env pwsh
# Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
. /opt/idssys/powerwall/settings.ps1
Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
$ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | 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!"
}
$VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM
Foreach ($VM in $VMLIST) {
while((Get-VM $VM).PowerState -ne 'PoweredOff') {
write-host waiting
Start-Sleep -Seconds 1
}
}
exit 0
Disconnect-VIServer $ESXI -Confirm:$false

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env pwsh
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
# Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
. /opt/idssys/powerwall/settings.ps1
$ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null

View File

@@ -1,22 +1,17 @@
#!/usr/bin/env pwsh
# Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
. /opt/idssys/powerwall/settings.ps1
Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
$ESXI = 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!"
}
$VMLIST = Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'}
Foreach ($VM in $VMLIST) {
while((Get-VM $VM).PowerState -ne 'PoweredOff') {
write-host waiting
Start-Sleep -Seconds 1
}
}
exit 0
Disconnect-VIServer $ESXI -Confirm:$false