PowerCLI report on datastores, overprovision and number of powered on VM´s

Today I had an reason for running PowerCLI again, the case was to get an quick report on the datastores at a customer, I have made a post about the one-liner that get the number of running VM´s on a datastore. As i described in that post, if your SAN does not support VAAI then you do not want to many VM´s on each datastore because of the SCSI-locking that can occur. This is just an extension of that because we also wanted to check how overprovisioned the datastores was (when using thin provisioning there is a risk that you will fill your datastores as the VM´s fill their vmdk disk´s)

The PowerCLI code looks like this

Get-Datastore | Select Name,@{N="TotalSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}},@{N="UsedSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace)/1GB,0)}}, @{N="ProvisionedSpaceGB";E={[Math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,0)}},@{N="NumVM";E={@($_ | Get-VM | where {$_.PowerState -eq "PoweredOn"}).Count}} | Sort Name | Export-Csv -Path C:\temp\vmds-datastore.csv -NoTypeInformation -UseCulture

And this is when i have run it on my test system, the difference here is that i removed the Export-CSV to get the output in the console

And here is a simple excel report

 

Comments

Kesshin
Reply

Thank you very much for posting this! I needed this exact report and it worked without a hitch!

vineeth
Reply

Hi Niklas

i want info simlar to this..My senerio is like this..
i have a 10node cluster (cluster name -xyz) with 223 vms here issue is 5 esxi host are mounted with max limit luns(255)and left over esxi boxs are mounted of 200 luns etc.. in the same cluster and these luns are also multimapped to diffrerent cluster in datacenter..and in that 255 luns some vms are running which are not related to this cluster.
here i need a script to know
1)which lun mapping is missing on the which host in the cluster
2)and which luns containg vms which are not related to this xyz cluster.

rahul
Reply

Hi is there a way to add vm name with host and cluster for on this, if yes please send me the command.

sean
Reply

To find the overprovisioned amount, add this as another variable. It would go right after the comma, but before the @{N=”NumVM”

@{N=”AmountOverprovisionedGB”;E={[Math]::Round(($_.ExtensionData.Summary.Uncommitted – $_.ExtensionData.Summary.FreeSpace)/1GB,0)}},

Hari
Reply

TotalSpaceGB UsedSpaceGB ProvisionedSpaceGB AmountOverprovisionedGB NumVM
8192 559 577 -7615 0
8192 284 309 -7883 0
8192 1707 1707 -6485 1
8192 309 309 -7883 1
8192 86 170 -8022 1
8192 1707 1707 -6485 1

Hari
Reply

for the ppl looking to add naaid ,
Get-Datastore | Select Name,@{N=”naaid”;E={$_.extensiondata.info.vmfs.extent.diskname}},@{N=”TotalSpaceGB”;E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}},@{N=”UsedSpaceGB”;E={[Math]::Round(($_.ExtensionData.Summary.Capacity – $_.ExtensionData.Summary.FreeSpace)/1GB,0)}}, @{N=”ProvisionedSpaceGB”;E={[Math]::Round(($_.ExtensionData.Summary.Capacity – $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,0)}},@{N=”AmountOverprovisionedGB”;E={[Math]::Round(($_.ExtensionData.Summary.Uncommitted – $_.ExtensionData.Summary.FreeSpace)/ 1GB,0)}},@{N=”NumVM”;E={@($_ | Get-VM | where {$_.PowerState -eq “PoweredOn”}).Count}} | Sort Name | ft * -AutoSize

Hari
Reply

can we use if in the select object , cause i plan to send this as alert as email

Leave a Reply to HariCancel reply

name*

email* (not published)

website