update
This commit is contained in:
@@ -6,7 +6,15 @@ Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Passwo
|
|||||||
$vmhosts=$args[0].Split(",")
|
$vmhosts=$args[0].Split(",")
|
||||||
Foreach ($vmhost in $vmhosts)
|
Foreach ($vmhost in $vmhosts)
|
||||||
{
|
{
|
||||||
Get-VMHost | Where {$_.Name -eq $vmhost} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} | Shutdown-VMGuest -Confirm:$false
|
$vms=Get-VMHost | Where {$_.Name -eq $vmhost} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'}
|
||||||
|
Foreach ($vm in $vms)
|
||||||
|
{
|
||||||
|
$migrating=Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq $vm -and $_.Description -like '*Relocate*' -and $_.State -eq 'Running'}
|
||||||
|
if ([string]::IsNullOrEmpty($migrating)) {
|
||||||
|
write-host "Shutting down "+$vm
|
||||||
|
#Get-VM $vm | Shutdown-VMGuest -Confirm:$false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false
|
Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ SHUTDOWN_SERVER(){
|
|||||||
c=0; MSG_SPC=''; spc1=`expr ${HC_CW} - ${#MSG}`; until [ ${c} = ${spc1} ]; do MSG_SPC="${MSG_SPC} "; ((c++)); done
|
c=0; MSG_SPC=''; spc1=`expr ${HC_CW} - ${#MSG}`; until [ ${c} = ${spc1} ]; do MSG_SPC="${MSG_SPC} "; ((c++)); done
|
||||||
echo -en "${idsCL[White]}${MSG}${MSG_SPC}: "
|
echo -en "${idsCL[White]}${MSG}${MSG_SPC}: "
|
||||||
if [ "${TEST}" != "true" ]; then
|
if [ "${TEST}" != "true" ]; then
|
||||||
sleep 35s
|
sleep 45s
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
else
|
else
|
||||||
echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}"
|
echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user