Hi All,
I am looking for a script using powercli to get cluster inventory information like memory,CPU, Disk resources mentioned below format
VC name:
DC Name:
Cluster Name:
Memory
Total Physical Memory:
Configured/Used Memory:
Available Memory:
CPU
Total CPU (MHZ):
Configured/Used CPU:
Available CPU:
Datastore:
Total Disk space (VMFS store):
Configured Disk space (VMFS store):
Available Disk space (VMFS store:
Our infrastrcture: Majority are ESX 4.0 & few are ESX 3.5, vCenter is 4.0
Thanks
Pranab
Try this
foreach($cluster in Get-Cluster){ $esx = $cluster | Get-VMHost
$ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS"}
$cluster | Select @{N="VCname";E={$cluster.Uid.Split(':@')[1]}}, @{N="DCname";E={(Get-Datacenter -Cluster $cluster).Name}}, @{N="Clustername";E={$cluster.Name}}, @{N="Total Physical Memory (MB)";E={($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum}}, @{N="Configured Memory MB";E={($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum}}, @{N="Available Memroy (MB)";E={($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum}}, @{N="Total CPU (Mhz)";E={($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum}}, @{N="Configured CPU (Mhz)";E={($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum}}, @{N="Available CPU (Mhz)";E={($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum}}, @{N="Total Disk Space (MB)";E={($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum}}, @{N="Configured Disk Space (MB)";E={($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum}}, @{N="Available Disk Space (MB)";E={($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum}} }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Thanks for the script. Can we get the output of the script in CSV format. Also is there any we can get only SAN/iSCSI VMFS volume details instead local ESX VMFS volumes.Also how can we run it only in single cluster.
Thanks
Pranab
Here you go.
If you want the report for a single cluster, change the $clusterName assignment.
With "*" the script will report on all clusters.
The datastores now only contain VMFS datastores that allow multiple host access.
$report = @() # $clusterName = "MyCluster"
$clusterName = "*"
foreach($cluster in Get-Cluster -Name $clusterName){ $esx = $cluster | Get-VMHost
$ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess} $row = "" | Select VCname,DCname,Clustername,"Total Physical Memory (MB)", "Configured Memory MB","Available Memroy (MB)", "Total CPU (Mhz)","Configured CPU (Mhz)", "Available CPU (Mhz)","Total Disk Space (MB)", "Configured Disk Space (MB)","Available Disk Space (MB)"
$row.VCname = $cluster.Uid.Split(':@')[1] $row.DCname = (Get-Datacenter -Cluster $cluster).Name $row.Clustername = $cluster.Name $row."Total Physical Memory (MB)" = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum $row."Configured Memory MB" = ($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum $row."Available Memroy (MB)" = ($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum $row."Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum $row."Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum $row."Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum $row."Total Disk Space (MB)" = ($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum $row."Configured Disk Space (MB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum $row."Available Disk Space (MB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum $report += $row
} $report | Export-Csv "C:\Cluster-Report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
I am getting this error when trying to run the scripts
Get-VMHost : Cannot validate argument on parameter 'Name'. The argument is null
or empty. Supply an argument that is not null or empty and then try the comman
d again.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\data12.ps1:6 c
har:33
+ $esx = $cluster | Get-VMHost <<<< $ds = Get-Datastore -VMHost $esx |
where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess}
+ CategoryInfo : InvalidData: (:) [Get-VMHost], ParameterBindingV
alidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.Commands.GetVMHost
You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\data12.ps1:13
char:37
+ $row.VCname = $cluster.Uid.Split <<<< (':@')[1]
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
Please help
The copy/paste apparently removed a <CR><LF>.
I corrected it. Can you try again ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Now getting below mentioned error. Datastore fields on CSV file is empty..other fields looks ok
You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\data1.ps1:14 c
har:37
+ $row.VCname = $cluster.Uid.Split <<<< (':@')[1]
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-Datastore : Cannot validate argument on parameter 'VMHost'. The argument is
null or empty. Supply an argument that is not null or empty and then try the c
ommand again.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\data1.ps1:7 ch
ar:32
+ $ds = Get-Datastore -VMHost <<<< $esx | where {$_.Type -eq "VMFS" -and $
_.Extensiondata.Summary.MultipleHostAccess}
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.Commands.GetDatastore
What value did you specify for $clusterName ?
It looks as if the
Get-Cluster -Name $clusterName
didn't return anything.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have kept same as mentioned by you "*" for getting info of all the cluters
Hi Luc,
Below mnetioned error I am getting and below mentioned rows in CSV file is empty not able to fetch datastore details
Total Disk Space (MB) Configured Disk Space (MB) Available Disk Space (MB)
You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\test1.ps1:13 c
har:37
+ $row.VCname = $cluster.Uid.Split <<<< (':@')[1]
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-Datastore : Cannot validate argument on parameter 'VMHost'. The argument is
null or empty. Supply an argument that is not null or empty and then try the c
ommand again.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\test1.ps1:6 ch
ar:32
+ $ds = Get-Datastore -VMHost <<<< $esx | where {$_.Type -eq "VMFS" -and $
_.Extensiondata.Summary.MultipleHostAccess}
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.Commands.GetDatastore
Please help.
Thanks
Pranab
Hi Luc,
When I removed "-and $_.Extensiondata.Summary.MultipleHostAccess" I am getting entire VMFS siz including local also.
Below mentioned command is not working. Can we get nos of hosts & VMs in the cluster also.
$ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess}
Also how can I get memory in GB instead of MB for Datastores & Date/Time stamp on the report.
Thanks
It looks as if you're not using the latest PowerCLI build.
Can you do a
Get-PowerCLIVersion
to check ?
In any case, the following version of the script will also work with older PowerCLI builds.
And the values are now in GB
$report = @() # $clusterName = "MyCluster"
$clusterName = "*" foreach($cluster in Get-Cluster -Name $clusterName){ $esx = $cluster | Get-VMHost $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-View $_).Summary.MultipleHostAccess} $row = "" | Select VCname,DCname,Clustername,"Total Physical Memory (GB)", "Configured Memory (GB)","Available Memroy (GB)", "Total CPU (Mhz)","Configured CPU (Mhz)", "Available CPU (Mhz)","Total Disk Space (GB)", "Configured Disk Space (GB)","Available Disk Space (GB)" $row.VCname = $cluster.Uid.Split(':@')[1] $row.DCname = (Get-Datacenter -Cluster $cluster).Name $row.Clustername = $cluster.Name $row."Total Physical Memory (GB)" = "{0:f1}" -f (($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum / 1KB) $row."Configured Memory (GB)" = "{0:f1}" -f (($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum / 1KB) $row."Available Memroy (GB)" = "{0:f1}" -f (($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum / 1KB) $row."Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum $row."Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum $row."Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum $row."Total Disk Space (GB)" = "{0:f1}" -f (($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum / 1KB) $row."Configured Disk Space (GB)" = "{0:f1}" -f (($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum / 1KB) $row."Available Disk Space (GB)" = "{0:f1}" -f (($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum / 1KB) $report += $row
} $report | Export-Csv "C:\Cluster-Report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
I am using PowerCLI Version "VMware vSphere PowerCLI 4.0 U1 build 208462" and vCenter version is vCenter 4.0 build 20811. After running the updated script I am getting below mentioned errors
Get-View : 2/22/2011 11:55:22 PM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:7
char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (FC-Dtrace-CX4-0168-117-18:Data
storeImpl) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/22/2011 11:55:22 PM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:7
char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (dtrasna01sesx04:storage1:Datas
toreImpl) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:13
char:109
+ "Configured Disk Space (GB)","Available Disk Space (GB)" $
row.VCname = $cluster.Uid.Split <<<< (':@')[1]
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
Property 'DCname' cannot be found on this object; make sure it exists and is se
ttable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:14
char:10
+ $row. <<<< DCname = (Get-Datacenter -Cluster $cluster).Name
+ CategoryInfo : InvalidOperation: (DCname:String) [], RuntimeExc
eption
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Clustername' cannot be found on this object; make sure it exists and
is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:15
char:10
+ $row. <<<< Clustername = $cluster.Name
+ CategoryInfo : InvalidOperation: (Clustername:String) [], Runti
meException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Total Physical Memory (GB)' cannot be found on this object; make sure
it exists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:16
char:10
+ $row. <<<< "Total Physical Memory (GB)" = "{0:f1}" -f (($esx | Measure-Ob
ject -Property MemoryTotalMB -Sum).Sum / 1KB)
+ CategoryInfo : InvalidOperation: (Total Physical Memory (GB):St
ring) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Configured Memory (GB)' cannot be found on this object; make sure it
exists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:17
char:10
+ $row. <<<< "Configured Memory (GB)" = "{0:f1}" -f (($esx | Measure-Object
-Property MemoryUsageMB -Sum).Sum / 1KB)
+ CategoryInfo : InvalidOperation: (Configured Memory (GB):String
) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Available Memroy (GB)' cannot be found on this object; make sure it e
xists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:18
char:10
+ $row. <<<< "Available Memroy (GB)" = "{0:f1}" -f (($esx | Measure-Object
-InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum / 1KB)
+ CategoryInfo : InvalidOperation: (Available Memroy (GB):String)
[], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Total CPU (Mhz)' cannot be found on this object; make sure it exists
and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:19
char:10
+ $row. <<<< "Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalM
hz -Sum).Sum
+ CategoryInfo : InvalidOperation: (Total CPU (Mhz):String) [], R
untimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Configured CPU (Mhz)' cannot be found on this object; make sure it ex
ists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:20
char:10
+ $row. <<<< "Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuU
sageMhz -Sum).Sum
+ CategoryInfo : InvalidOperation: (Configured CPU (Mhz):String)
[], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Available CPU (Mhz)' cannot be found on this object; make sure it exi
sts and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:21
char:10
+ $row. <<<< "Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$
_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum
+ CategoryInfo : InvalidOperation: (Available CPU (Mhz):String) [
], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Total Disk Space (GB)' cannot be found on this object; make sure it e
xists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:22
char:10
+ $row. <<<< "Total Disk Space (GB)" = "{0:f1}" -f (($ds | where {$_.Type -
eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum / 1KB)
+ CategoryInfo : InvalidOperation: (Total Disk Space (GB):String)
[], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Configured Disk Space (GB)' cannot be found on this object; make sure
it exists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:23
char:10
+ $row. <<<< "Configured Disk Space (GB)" = "{0:f1}" -f (($ds | Measure-Obj
ect -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum / 1KB)
+ CategoryInfo : InvalidOperation: (Configured Disk Space (GB):St
ring) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Available Disk Space (GB)' cannot be found on this object; make sure
it exists and is settable.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:24
char:10
+ $row. <<<< "Available Disk Space (GB)" = "{0:f1}" -f (($ds | Measure-Obje
ct -Property FreeSpaceMB -Sum).Sum / 1KB)
+ CategoryInfo : InvalidOperation: (Available Disk Space (GB):Str
ing) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Get-View : 2/22/2011 11:55:27 PM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:7
char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (ESX-167-Storage1:DatastoreImpl
) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/22/2011 11:55:36 PM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster.ps1:7
char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (FC-SharePointTest-CX4-0569-156
-56:DatastoreImpl) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Thanks
Pranab
It seems that the Get-Cluster or Get-VMHost cmdlets at the beginning of the script didn't work.
Does this return anything ?
Get-Cluster -Name "*"
I have again attached the script to avoid any copy/paste problems.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
If I am running the script in VMware vSphere PowerCLI 4.1 U1 build 332441 version, it is not giving any error (vCenter 4.1 build 258902) -LAB setup
If I am running the script in VMware vSphere PowerCLI 4.0 U1 build 208462 version,(vCenter 4.0 build 20811) it is giving below mentioned error.- Production
> .\cluster-report-configured-used-available.ps1
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (172.24.13.35-local:DatastoreIm
pl) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-11:DatastoreImpl) [
Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-8:DatastoreImpl) [G
et-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-9:DatastoreImpl) [G
et-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-10:DatastoreImpl) [
Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-1:DatastoreImpl) [G
et-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-2:DatastoreImpl) [G
et-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LAB-FC-LUN-4:DatastoreImpl) [G
et-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (172.24.13.32-local:DatastoreIm
pl) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/23/2011 12:32:01 AM Get-View Invalid object specified fo
r parameter Id - 'DatastoreImpl'. Valid types are ManagedObjectReference and st
ring.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:7 char:80
+ $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-Vi
ew <<<< $_).Summary.MultipleHostAccess}
+ CategoryInfo : InvalidArgument: (LABESX-03-Storage1:DatastoreIm
pl) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware
.VimAutomation.Commands.DotNetInterop.GetVIView
You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\cluster-report
-configured-used-available.ps1:14 char:37
+ $row.VCname = $cluster.Uid.Split <<<< (':@')[1]
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
Hi Luc,
I have updated the powercli to latest version & script in working fine.For on host in the cluster it showing black space for the storage.How can we add nos of hosts & VMs in the list along with Date & time.
Thanks
Pranab
Sure, try this
$report = @() # $clusterName = "MyCluster"
$clusterName = "*" foreach($cluster in Get-Cluster -Name $clusterName){ $esx = $cluster | Get-VMHost $ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and (Get-View $_).Summary.MultipleHostAccess} $row = "" | Select VCname,DCname,Clustername,"Total Physical Memory (GB)", "Configured Memory (GB)","Available Memroy (GB)", "Total CPU (Mhz)","Configured CPU (Mhz)", "Available CPU (Mhz)","Total Disk Space (GB)", "Configured Disk Space (GB)","Available Disk Space (GB)", "Nr of hosts","Nr of VMs"
$row.VCname = $cluster.Uid.Split(':@')[1] $row.DCname = (Get-Datacenter -Cluster $cluster).Name $row.Clustername = $cluster.Name $row."Total Physical Memory (GB)" = "{0:f1}" -f (($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum / 1KB) $row."Configured Memory (GB)" = "{0:f1}" -f (($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum / 1KB) $row."Available Memroy (GB)" = "{0:f1}" -f (($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum / 1KB) $row."Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum $row."Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum $row."Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum $row."Total Disk Space (GB)" = "{0:f1}" -f (($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum / 1KB) $row."Configured Disk Space (GB)" = "{0:f1}" -f (($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum / 1KB) $row."Available Disk Space (GB)" = "{0:f1}" -f (($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum / 1KB) $row."Nr of hosts" = @($esx).Count $row."Nr of VMs" = ($esx | Measure-Object -InputObject {$_.Extensiondata.Vm.Count} -Sum).Sum $report += $row
} $report | Export-Csv "C:\Cluster-Report.csv" -NoTypeInformation -UseCulture
For the missing datastore I suspect that this is a non-VMFS datastore.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
For Configured Memory,Configured CPU in how it is calculating. If suppose I have 2 Hosts with 16GB & 2CPUs(2GHz) then total I have in the cluster
Total Memory: 32GB
Total CPU: 8GHz
So If i reserve 800MB for both the service console & have 3 VMs with 2GB memory & 1 CPU each then what will be the configured & available memory in the cluster.
Thanks
Pranab
You should see the Configured values (memory & cpu) increase and the Available values decrease accordingly.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great Script, but I am getting the following error when run all the rest of the infomation is reported except the number of hosts and number of vm;
Property `Nr of hosts` cannot be found on this object; make sure it exists and is settable.
Thanks,