I have a quick one liner that pulls the space used on each DS and the # of VM's. Im looking to add the cluter to this but cant seem to figure it out.... Id like it to run against vsphere and pull the cluster and add the cluster name to the spreadsheet as well.
#Run Connect-VIServer "vcenterservername" from powercli before running this script.... no need to add it to this script.
$vcenter = $defaultVIServers
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 H:\Excel_Reports\DS_Report.$vcenter.csv -NoTypeInformation -UseCulture
A quick-and-dirty way of doing this
Get-Datastore |
Select Name,
@{N="Cluster";E={Get-VMHost -Datastore $_ | Select -First 1 | Get-Cluster | Select -ExpandProperty 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 H:\Excel_Reports\DS_Report.$vcenter.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
A quick-and-dirty way of doing this
Get-Datastore |
Select Name,
@{N="Cluster";E={Get-VMHost -Datastore $_ | Select -First 1 | Get-Cluster | Select -ExpandProperty 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 H:\Excel_Reports\DS_Report.$vcenter.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
@ Justin - I guess you are looking for datastore cluster
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}},
@{N="DatastoreCluster";E={$_ | Get-DatastoreCluster}} |
Sort Name | Export-Csv -Path H:\Excel_Reports\DS_Report.$vcenter.csv -NoTypeInformation -UseCulture
@LucD - That worked wonders. I had to remove the dev* but Im assuming you left it in when you were testing it
Once again, thanks for the help.
Oops, indeed a relic from my test environment :smileyblush:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference