Hi,
In my client env, we have multiple application type folder. In each folder we have multiple vms, including cluster vms.
We need to get total used space and provisioned space for each folder.
As well requirement is cluster disk must be calculated only one time. Please help me for this...
-a
I'm thinking of a filter to maybe get all VM's that show up as an RDM or shared vmdk and filter those out of the Get-VM collection.
Then add those together separately, combining likeness of the filename maybe? If you can run this RDM Script, then I can see what the data might look like to adjust. I don't have any RDM's to play with on my end unfortunately, all NFS these days.
$report = @()
$vms = Get-VM |Sort Name -Descending | Get-View
foreach($vm in $vms)
{
foreach($dev in $vm.Config.Hardware.Device)
{
if(($dev.gettype()).Name -eq "VirtualDisk")
{
if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or ($dev.Backing.CompatibilityMode -eq "virtualMode"))
{
$row = "" | select VMName, HDDeviceName, HDFileName, HDMode, HDSize
$row.VMName = $vm.Name
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$row.HDMode = $dev.Backing.CompatibilityMode
$row.HDSize = [math]::Round((($dev.CapacityInKB)/1048576),2)
$report += $row
}
}
}
}
The cluster aspect will be a little more difficult. Will have to stew on that a bit.:smileyconfused:
Here is a starting point:
$Report = @()
$Folders = Get-Folder
Foreach ($Folder in $Folders)
{
$FolderVMs = $folder | get-vm
If ($FolderVMs) #Essentially checking if any VM's were returned.
{
$TempObject = "" | Select FolderName, ProvisionedSpace, UsedSpace
$TempObject.FolderName = $folder.name
$TempObject.ProvisionedSpace = [math]::truncate(($FolderVMs | Measure-Object -Property ProvisionedSpaceGB -Sum).SUM)
$TempObject.UsedSpace = [math]::truncate(($FolderVMs | Measure-Object -Property UsedSpaceGB -Sum).SUM)
$Report += $TempObject
}
}
$Report
Are they RDM's or vmdk's that are shared?
Yes these rdm are shared (MSCS clusters).
Thanks for the script, this is not working
I am just trying to get the provisioned space and used space parameter, Not working
-A
Make this correction at 8th line, it will be working.
$TempObject = "" | Select FolderName, ProvisionedSpace, UsedSpace
will try and update ..
hehe, oops. thanks for pointing that out.
Thanks Script is working....
For MSCS RDM shared disk , Script is calculating twice
Is there any fix for this.
-A
I'm thinking of a filter to maybe get all VM's that show up as an RDM or shared vmdk and filter those out of the Get-VM collection.
Then add those together separately, combining likeness of the filename maybe? If you can run this RDM Script, then I can see what the data might look like to adjust. I don't have any RDM's to play with on my end unfortunately, all NFS these days.
$report = @()
$vms = Get-VM |Sort Name -Descending | Get-View
foreach($vm in $vms)
{
foreach($dev in $vm.Config.Hardware.Device)
{
if(($dev.gettype()).Name -eq "VirtualDisk")
{
if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or ($dev.Backing.CompatibilityMode -eq "virtualMode"))
{
$row = "" | select VMName, HDDeviceName, HDFileName, HDMode, HDSize
$row.VMName = $vm.Name
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$row.HDMode = $dev.Backing.CompatibilityMode
$row.HDSize = [math]::Round((($dev.CapacityInKB)/1048576),2)
$report += $row
}
}
}
}
I will try to integrate both of them and will post the result ASAP.
-a