VMware Cloud Community
Ricardo_vodafon
Contributor
Contributor
Jump to solution

PowerCli Disk Over Commit

Hi

How can i check if one datastore is "disk over commit" ? It is possible to obtain the size in GB or MB disk allocation?

I need to do this by powercli command.

Thks.

Ricardo Marques

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can try something like this

Get-View -ViewType Datastore | Select Name, 
	@{N="CapacityGB";E={$_.Summary.Capacity/1GB}},
	@{N="ProvisionedGb";E={($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB}},
	@{N="FreeGB";E={$_.Summary.FreeSpace/1GB}}

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

You can try something like this

Get-View -ViewType Datastore | Select Name, 
	@{N="CapacityGB";E={$_.Summary.Capacity/1GB}},
	@{N="ProvisionedGb";E={($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB}},
	@{N="FreeGB";E={$_.Summary.FreeSpace/1GB}}

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

And if you're running PowerCLI 4.1, you can do

New-VIProperty -Name ProvisionedGB -ObjectType Datastore -Value {
	param($ds)
	
	[Math]::Round(($ds.ExtensionData.Summary.Capacity - $ds.ExtensionData.FreeSpace + $ds.ExtensionData.Summary.Uncommitted)/1GB,1)
} -BasedONextensionProperty 'Summary' -Force

New-VIProperty -Name CapacityGB -ObjectType Datastore -Value {
	param($ds)
	
	[Math]::Round($ds.CapacityMB/1KB,1)
} -Force

New-VIProperty -Name FreeGB -ObjectType Datastore -Value {
	param($ds)
	
	[Math]::Round($ds.FreeSpaceMb/1KB,1)
} -Force

Get-Datastore | Select Name,CapacityGB,FreeGB,ProvisionedGB

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
Ricardo_vodafon
Contributor
Contributor
Jump to solution

Hi

Yes i have the last version of powercli installed. When i run the last code i have the following error:

The term 'New-VIProperty' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At :line:4 char:14

+ New-VIProperty <<<< -Name ProvisionedGB -ObjectType Datastore -Value {

The first code works fine.

Thks.

Ricardo Marques

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Do a

Get-PowerCLIVersion

I'm pretty sure it won't say 4.1.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
Ricardo_vodafon
Contributor
Contributor
Jump to solution

I have the following version installed:

PowerCLI Version

-


VMware vSphere PowerCLI 4.0 U1 build 208462

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That's not the latest version.

You cna get PowerCLI 4.1 here.

But be aware that there is an issue with some of PowerGui's PowerPacks and EcoShell and PowerCLI 4.1.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
Pedwards
Contributor
Contributor
Jump to solution

I do have the latest (PowerCLI 4.1 U1 Build 332441) and this script does execute without errors.  The problem is that it returns all zeroes for capacityGB, FreeGB and ProvisionedGB.

This is the first script I have found that returns usable data in my environment (posted by LucD):

Get-View -ViewType Datastore | Select Name,
>>      @{N="CapacityGB";E={$_.Summary.Capacity/1GB}},
>>      @{N="ProvisionedGb";E={($_.Summary.Capacity - $_.Summary.FreeSpace + $_.
Summary.Uncommitted)/1GB}},
>>      @{N="FreeGB";E={$_.Summary.FreeSpace/1GB}}

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I assume that

Get-View -ViewType Datastore

on it's own returns the datastores ?

And what does this show

Get-View -ViewType Datastore | Select -ExpandProperty Summary


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

0 Kudos
Pedwards
Contributor
Contributor
Jump to solution

"Get-View - ViewType Datastore" spits out about 5000 lines of useless data.  Accurate, but needlessly verbose.

"Get-View -ViewType Datastore | Select -ExpandProperty Summary"  Produces the following error multiple times:

Select-Object : Cannot expand property "Summary" because it has nothing to expand.
At line:1 char:38

Again, your first script that I cited in my post is the only one I've found that actually works for me.

0 Kudos