Hi,
Can someone help me figure something out? I have a basic datastore report that works as expected in PowerCLI 4.1.1.2816 (on Server 2003) but does not work on PowerCLI 5.0.1.4431 (Server 2008).
+++++
$Report = @()
Connect-VIServer $VIServer -user $username -password $password
Get-View -ViewType Datastore | Sort-Object Name | %{
$Store = {} | Select Name, Capacity
$Store.Name = $_.Name
$Store.Capacity = [math]::Round($_.capacityMB/1024,2)
$Report += $Store
}
Disconnect-VIServer -Confirm:$False
++++++
The problem is that $_.capacityMB returns "0" for each datastore on 5.0.1.4431 on (Server 2008). Works fine on 4.1.1...
To simplify I've also tried:
$Store.Capacity = $_.capacityMB
(removing the math function)
Same issue.
Any ideas? I need to upgrade my script and move it to the new version of PowerCLI.
Mike
Apologies, the version is 5.1.0.4977 (the latest from September 2012 which does not work).
Hi
can you try this ?
$Report = @()
Connect-VIServer $VIServer -user $username -password $password
Get-View -ViewType Datastore | Sort-Object Name | %{
$Store = {} | Select Name, Capacity
$Store.Name = $_.Name
$Store.Capacity = $_.summary.capacity/1GB
$Report += $Store
}
Disconnect-VIServer -Confirm:$False
Greg
That did it, Greg. Thank you kindly for your help.
would you mind helping me with one more item? How can I retrieve all available summary items from get-datastore or get-view -viewtype datastore? If I run just a basic get-datastore it gives me the following two summary items:
CapacityGB
FreeSpaceGB
Are there more I can retrieve?
Thanks again.
for example
take 1 random ds
$a=get-view -ViewType datastore | select -First 1
type
$a
type $a.info
properties:
Vmfs
Name
Url
FreeSpace
MaxFileSize
Timestamp
type $a.summary
properties:
Datastore
Name
Url
Capacity -> here was the capacity
FreeSpace
Uncommitted
Accessible
MultipleHostAccess
Type
MaintenanceMode
I think those would be the most interesting for you when it goes about properites.
You can use all of those properties as you want.
This is great, thanks again.
Mike