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 " ================ Apply DRS recomendations ================"  -ForegroundColor green
Write-Host " Do you want to apply the DRS Recomendations" 
Write-Host " Yes"
Write-Host " No"
$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');
 #Enter Function name here for previous menu or exit
 #Enter Function name here for previous menu or exit

 2,002 total views,  3 views today

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.