List DRS Recommendations and apply them

Heres a function i put together that pulls a list of DRS recommendations for your chosen cluster then asks whether you want to apply them. It uses my usual variables from my menu system

$Global:DCChoice – Datacenter Choice
$global:CLUChoice – Cluster Choice

#Apply DRS recomendations?  
function VP-ApplyDRSRecommendations
{
Get-Datacenter $global:DCChoice | Get-Cluster $global:CLUChoice | Get-DrsRecommendation
Write-Host
Write-Host " ================ Apply DRS recomendations ================"  -ForegroundColor green
Write-Host
Write-Host " Do you want to apply the DRS Recomendations" 
Write-Host
Write-Host " Yes"
Write-Host " No"
Write-Host
$Global:InstallSelection = Read-Host " Please make a selection (Q to Quit)"

if($Global:InstallSelection -like 'yes'){
 Get-Datacenter $global:DCChoice | Get-Cluster $global:CLUChoice | Get-DrsRecommendation | Apply-DRSRecommendation 
 Write-Host -NoNewLine 'Complete. Press any key to continue...';
 $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
 clear
 #Enter Function name here for previous menu or exit
}
else{
 Clear
 #Enter Function name here for previous menu or exit
}
}

Loading

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.