- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello - I am looking to pull the DatastoreClusters and then list the datastores as well with their size (total size, Used space, Free Space, Provisioned, Uncommitted space) and the total number of VM's on that datastore. I would also like to include what datacenter and clusters they are on. Is this possible? I would like to maybe limit what is shown to datastores that are 13% free space or less.
Thanks,
Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this
foreach($dsc in Get-DatastoreCluster){
Get-Datastore -Location $dsc |
Select @{N='DSC';E={$dsc.Name}},Name,CapacityGB,@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this looks great - is there a way I can get it to be exported? do I just add Export-Csv z:\newdatastorereport1.csv -NoTypeInformation after the end bracket? will that work?
Also - will this pick up datastores that are not part of a cluster? We have a combination of DatastoreClusters as well as just datastores. So is there a way to pull in the what DataCenter cluster it's in? I am really looking for a way to monitor and manage the datastores - I can't seem to find a good tool.
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, try it this way
Get-Datastore |
Select @{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}},
Name,CapacityGB,@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}} |
Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks this is great! One last thing - if I want to only show datastores that are less than 13% free - how do I add that? Also - Is there any way to create totals? Like create a total by DatastoreCluster - total capacity, free space, provisioned, uncommitted, VM count?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To only see datastores that have 13% or less free space, you can add Where-clause
Get-Datastore |
where {($_.FreeSpaceGB/$_.CapacityGB) -le 0.13} |
Select @{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}},
Name,CapacityGB,@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}} |
Export-Csv report.csv -NoTypeInformation -UseCulture
How do you want to see these datastorecluster totals ?
It's difficult to have those in the same CSV file.
Can these go to another CSV file ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I think that another cvs would be fine. I need to figure out a way to display this info anyways.
How can I add the free percentage column as well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Lucd,
Can you please help me to get it output from the multiple vCenter. I have totally 10vCenter, Please modify the same scripts and let me know,
Thanks in Advance,
Yuvaraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try like this.
You need to connect to all vCenters before running the script
$report = foreach($vc in $global:DefaultVIServers){
Get-Datastore -Server $vc |
where {($_.FreeSpaceGB/$_.CapacityGB) -le 0.13} |
Select @{N='vCenter';E={$vc.Name}},
@{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ -Server $vc | Select -ExpandProperty Name}},
Name,CapacityGB,@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}}
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi LucD, this is good! Anyway to modify the logic so along with FreespaceGB it can give you percentage (%) free? I'd like to run this on a scheduled basis against each of my vCenters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this
$report = foreach($vc in $global:DefaultVIServers){
Get-Datastore -Server $vc |
where {($_.FreeSpaceGB/$_.CapacityGB) -le 0.13} |
Select @{N='vCenter';E={$vc.Name}},
@{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ -Server $vc | Select -ExpandProperty Name}},
Name,CapacityGB,
@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='Freespace%';E={[math]::Round($_.FreespaceGB/$_.CapacityGB*100,1)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}}
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Worked like a champ! Thank you LucD!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi LucD, you provided me the percentage free which worked great. Thank you again! Anyway we can incorporate the datastore names associated with each datastore cluster?
$report = foreach($vc in $global:DefaultVIServers){
Get-Datastore -Server $vc |
where {($_.FreeSpaceGB/$_.CapacityGB) -le 0.13} |
Select @{N='vCenter';E={$vc.Name}},
@{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ -Server $vc | Select -ExpandProperty Name}},
Name,CapacityGB,
@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='Freespace%';E={[math]::Round($_.FreespaceGB/$_.CapacityGB*100,1)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}}
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The datastorename is in the Name column, or do you mean something else?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm looking for all the datastore names inside that make up the datastore cluster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mean like this (in DSCDSNames)?
$report = foreach($vc in $global:DefaultVIServers){
Get-Datastore -Server $vc |
where {($_.FreeSpaceGB/$_.CapacityGB) -le 0.13} |
Select @{N='vCenter';E={$vc.Name}},
@{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ -Server $vc | Select -ExpandProperty Name}},
@{N='DSCDSNames';E={(Get-DatastoreCluster -Datastore $_ -Server $vc | Get-Datastore | Select -ExpandProperty Name) -join '|'}}
Name,CapacityGB,
@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='Freespace%';E={[math]::Round($_.FreespaceGB/$_.CapacityGB*100,1)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}}
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Luc, my apologies, the current script does captures that information (DSCDSNames). What if I wanted to connect to 4 or 5 vCenters at one time to pull this information, would that put any sort of load on each of the VC's, and how can I do that? I'd like to run this once versus one at a time on each VC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I added the DSCDSNames properties just a minute ago.
When you connect to multiple vCenters you can run this scripts against all of these vCenters in one run.
Each query places some load on a vCenter, but so does a page refresh in the Web Client.
Besides, most of the actual calculations in that report are done on the station where you run the script.
The script already uses a ForEach loop, where it queries each of the connected vCenters one by one.
So it's not as if all vCenters will receive that same query at the same time.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LucD - Is there anyway to actually take this script and change it to pull a certain % of Provisioned space? We want to take a look at datastores that are provisioned over 175%.
Additionally I would like to also query provisioned space over 175% AND freespace % less than 5%
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mean something like this?
Get-Datastore |
where {((($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB)/$_.CapacityGB) -ge 1.75 -and
($_.FreeSpaceGB/$_.CapacityGB) -le 0.05} |
Select @{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}},
Name,CapacityGB,
@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}} |
Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference