Files
powerwall/esxi-scripts/set-drs.ps1
2024-11-09 19:00:37 -06:00

28 lines
1.1 KiB
PowerShell
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env pwsh
. /opt/idssys/powerwall/conf/settings.ps1
Write-Progress -Activity "Connecting to vCenter [$VCENTERHOST] ..." -PercentComplete 20
Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null
Write-Progress -Activity "Connected! Setting the new DRS Max vCPU ..." -PercentComplete 75
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.DrsConfig = New-Object VMware.Vim.ClusterDrsConfigInfo
$spec.DrsConfig.Option = New-Object VMware.Vim.OptionValue[] (1)
$spec.DrsConfig.Option[0] = New-Object VMware.Vim.OptionValue
$spec.DrsConfig.Option[0].Key = 'MaxVcpusPerCore'
$spec.DrsConfig.Option[0].Value = $args[0]
$cluster_ID= Get-Cluster -Name "iDS-Cluster"
$_this = Get-View -Id $cluster_ID.Id
$_this.ReconfigureComputeResource_Task($spec, $true)
Write-Progress -Activity "Refreshing DRS and invoking any DRS Recommendations ..." -PercentComplete 90
Get-Cluster -Name "iDS-Cluster" | Get-DrsRecommendation -Refresh | Invoke-DrsRecommendation
Write-Progress -Activity "Done" -Completed
Disconnect-VIServer -Server $VCENTERHOST -Force Confirm:$false