VMware Cloud Community
Buck1967
Contributor
Contributor
Jump to solution

simple script to list properties of all datastores

I've been looking over many scripts to get information about my datastores. I can quickly export most the properies I need right to a csv from vCenter. One glaring missing piece is the "Proviosoned Space" from the datastore list view. I have to look at the properties of each individual datastore to see that information. Is there a script that can pull that information?  For this script I don't reallt care about any info at the vm level.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Until they fix this you can use something like this

Get-Datastore | where {$_.Type -eq "VMFS"} | Select Name,
       @{N="Status";E={$_.Extensiondata.OverallStatus}},
       @{N="Device";E={$_.Extensiondata.Info.Vmfs.Extent[0].DiskName}},
       @{N="Capacity";E={"{0:f2} GB"-f ($_.CapacityMB /1KB)}},
       @{N="Free";E={"{0:f2} GB"-f ($_.FreeSpaceMB /1KB)}},
       @{N="Provisioned";E={"{0:f2} GB"-f (($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted) /1GB)}},
       @{N="Type";E={$_.Extensiondata.Info.Vmfs.Type.ToLower() + $_.Extensiondata.Info.Vmfs.MajorVersion}},
       @{N="Last Update";E={$_.Extensiondata.Info.Timestamp}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
9 Replies
mattboren
Expert
Expert
Jump to solution

Hello, @Buck1967-

There are serveral ways to do this, and a few people have posted some of the ways:

@DougBaer gives a couple at http://communities.vmware.com/message/1355848 , and @nkange gives a way at http://communities.vmware.com/message/1510283#1510283 .

Also, if you are into the New-VIProperty cmdlet, @LucD (of course) has a tidbit for creating a new property at http://www.lucd.info/viproperties/ under "ProvisionedGB".

Enjoy

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can use the New-VIproperty cmdlet to create a new property that shows the provisioned space.

See the ProvisionedGB entry in the Datastore section on my VIProperties page.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Buck1967
Contributor
Contributor
Jump to solution

I did use the  New-VIProperty cmdlet and it works but the provision space returned seems to be wrong. I guess I'll need to look into it more.

Reply
0 Kudos
Buck1967
Contributor
Contributor
Jump to solution

I love your website. keep up the awesome work there. My scripts skills leave a lot to be desired, but sites like this make me look good... Smiley Happy

Reply
0 Kudos
Buck1967
Contributor
Contributor
Jump to solution

frustrating my scripting skills are failing me,

I still haven't been able to get a script to function to get the provisioned space value for a datastore. Well at least a proper value. Smiley Sad

I can easily export from vCenter these properties:

IdentificationStatusDeviceCapacityFreeTypeLast Update

Where is "Provisioned Space"? Why would they leave this out.
and why would they change from a Gig metric to TB. I have a mixture of 500G, 1tb and 2tb LUNs. This is a pain just trying to determine exactly how much is from accross all the LUNs.

I hope they can fix this in a future version on vCenter.

Buck

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Until they fix this you can use something like this

Get-Datastore | where {$_.Type -eq "VMFS"} | Select Name,
       @{N="Status";E={$_.Extensiondata.OverallStatus}},
       @{N="Device";E={$_.Extensiondata.Info.Vmfs.Extent[0].DiskName}},
       @{N="Capacity";E={"{0:f2} GB"-f ($_.CapacityMB /1KB)}},
       @{N="Free";E={"{0:f2} GB"-f ($_.FreeSpaceMB /1KB)}},
       @{N="Provisioned";E={"{0:f2} GB"-f (($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted) /1GB)}},
       @{N="Type";E={$_.Extensiondata.Info.Vmfs.Type.ToLower() + $_.Extensiondata.Info.Vmfs.MajorVersion}},
       @{N="Last Update";E={$_.Extensiondata.Info.Timestamp}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Buck1967
Contributor
Contributor
Jump to solution

That is exactly what I'm looking for. I hope I don't mess it up to have it write it out to a CSV file.. Smiley Happy

Thanks for the scipt!!!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Just pipe the result to the Export-Csv cmdlet

Get-Datastore | where {$_.Type -eq "VMFS"} | Select Name,
       @{N="Status";E={$_.Extensiondata.OverallStatus}},
       @{N="Device";E={$_.Extensiondata.Info.Vmfs.Extent[0].DiskName}},
       @{N="Capacity";E={"{0:f2} GB"-f ($_.CapacityMB /1KB)}},
       @{N="Free";E={"{0:f2} GB"-f ($_.FreeSpaceMB /1KB)}},
       @{N="Provisioned";E={"{0:f2} GB"-f (($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted) /1GB)}},
       @{N="Type";E={$_.Extensiondata.Info.Vmfs.Type.ToLower() + $_.Extensiondata.Info.Vmfs.MajorVersion}},
       @{N="Last Update";E={$_.Extensiondata.Info.Timestamp}} | `
Export-Csv "C:\DS-report.csv" -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Buck1967
Contributor
Contributor
Jump to solution

Thank you very much... No even I can't mess that up Smiley Happy

Reply
0 Kudos