We are getting a number of consolidations needed every morning when coming in on our test environments, does anyone know the best way to setup a script to run to consolidate any vms that needed it?
I've tried using the below command:
connect-viserver VCENTERSERVER
Get-VM |
Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded} |
ForEach-Object {
$_.ExtensionData.ConsolidateVMDisks()
}
disconnect-viserver VCENTERSERVER -confirm:$FALSE
with a batch file pointing at it -
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\Consolidation_Script\Consolidation_Script.ps1
I've scheduled this, but still seeing vms needing consolidation, can anyone help?