JoyAntony
Contributor
Contributor

Assistance with PowerCLI script for Virtual Machine Disconsolidation

HI , I'm trying to create script to automate Virtual Machine Disk Consolidation due to TSM Backup which keeps creating alert on the VC , like scheduling weekly .

Script I have created , kindly guide me or let me know the right command

Connect-VIServer
-Server  <vCenter Server >

Get-VM | Where-Object
{$_.Extensiondata.Runtime.ConsolidationNeeded} | Export-Csv
C:\VMConsolidationDetails.Csv

{

Get-VM -Name (Import-Csv
C:\VMConsolidationDetails.Csv.| Where-Object
{$_.Extensiondata.Runtime.ConsolidationNeeded} ()

{

$vmList = Get-Content -Path
C:\VMConsolidationDetails.Csv

foreach ($vm in $vmList)

{

Get-VM |

Where-Object
{$_.Extensiondata.Runtime.ConsolidationNeeded} | ForEach-Object {

$_.ExtensionData.ConsolidateVMDisks_Task()

}

Get-vm $vm| %{ Write-Output
$_.ExtensionData.ConsolidateVMDisks() |
export-Csv -useculture -notypeinformation -path c:\Temp\OutputConsolidation.Csv

}

}

0 Kudos
0 Replies