Move a host into a cluster

This function pulls a list of hosts from your vCenter that are currently in maintenance mode and moves them into your previous selected cluster.
Again this uses my usual variables, specifically:
VP-MoveHostCluster – Function Name
$Global:DCChoice – DC Choice
$Global:CLUChoice – Cluster Choice

function VP-MoveHostCluster
{
$hosts = Get-datacenter $Global:DCChoice | get-vmhost | Where {$_.ConnectionState -eq "Maintenance"}
Write-Host " ================ Select host to move ================" -ForegroundColor green
$i = 1
$hosts | ForEach-Object -Process {
Write-Host " $i $($_.Name)"
$i++
}
$selection = Read-Host "Please make a selection (Q to Quit)"
if($selection -eq 'Q'){
clear
TTRF-Choice-Deploy-Menu
}
else{
$HostChoice = $hosts[$selection -1].Name
Write-Host " Moving $HostChoice into $Global:CLUChoice"
Start-Sleep -Second 1
Move-VMHost $HostChoice -Destination $Global:CLUChoice
}
}

 694 total views,  1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *