VMware Cloud Community
benham
VMware Employee
VMware Employee
Jump to solution

Get-Datastore Not Accurate FreeSpaceMB

Hi,

I use get-datastore to generate a report of datastore free space. I noticed that the free space reported matches to whatever value that is presented on VI Client Datastore View. However, that view is not accurate and a refresh is required to get an updated free space.

How can do refresh the free space value?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could use the SDK RefreshDatastore method.

foreach($ds in (Get-Datastore | Get-View)){
  $ds.RefreshDatastore()
} 


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

View solution in original post

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

You could use the SDK RefreshDatastore method.

foreach($ds in (Get-Datastore | Get-View)){
  $ds.RefreshDatastore()
} 


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

Reply
0 Kudos
benham
VMware Employee
VMware Employee
Jump to solution

Cool, it works. Cheers!

Reply
0 Kudos
balainfo
Contributor
Contributor
Jump to solution

I have 75 datastores and if i call the refreshDatastore() method every time i am getting free space, i have to do this 75 times - one for each datastore? This ends up slowing down vCenter and ultimately, even connections to vCenter fail for a while. Is there any other alternative? Please help.

R.

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

In PowerCLI 4.0 U1 we introduced Get-Datastore -Refresh, you might try it to see if it works any better.

If not, it is a vCenter limitation.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The new Get-Datastore -Refresh is considerable faster then the original RefreshDatastore script.

But the fastest method I could find is a script that use Get-View and RefreshDatastore

Get-View -ViewType Datastore -SearchRoot (Get-Datacenter <dcname> | Get-View).MoRef | %{$_.RefreshDatastore()}


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

Reply
0 Kudos
jeyakarthika
Contributor
Contributor
Jump to solution

Hi,

I am also facing the same problem.Can u provide the corresponding method in vi sdk for Get-Datastore-Refresh and Get-View +RefreshDatastore.

Thanks in advance

karthika

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The underlying SDK method for both ways is what I showed in my first answer in this thread.


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

Reply
0 Kudos
jeyakarthika
Contributor
Contributor
Jump to solution

Hi ,

I am also using the same method what u mentioned in first reply.It is taking more time to refresh the datastore.Is there any way to reduce the time taken using VI SDK?

FYI:

foreach($ds in (Get-Datastore | Get-View)){
  $ds.RefreshDatastore()
} 

Regards,

karthika

Reply
0 Kudos