I'm looking for a Power Shell script where I can run a weekly check on the 😧 (data) drive for a group of vm's and email the available space to a specified group of users in Exchange.
Thanks for all help.
Jeremy
This will give you a report on the free space of the D-partition for all your guests.
$report = @() foreach($vm in Get-VM){ $row = "" | Select VM,DFree $row.VM = $vm.Name $row.DFree = ($vm.Guest.Disks | where {$_.Path -like "d:\*"}).FreeSpace $report += $row} $report
The freespace is expressen in bytes. Do you want MB or GB ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
GB thanks.
Here you go, I use the format operator (-f) to pretty-print the value
$report = @()
foreach($vm in Get-VM mmmstd*){
$row = "" | Select VM,DFreeGB
$row.VM = $vm.Name
$row.DFreeGB = "{0:f0}"-f (($vm.Guest.Disks | where {$_.Path -like "d:\*"}).FreeSpace / 1GB)
$report += $row}
$report
To schedule a script have a look at Alan's post called Running a PowerCLI Scheduled task.
And to send a report by email have a look at the thread output to body of email.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the help.