Hi, How to generate a report of all the VM's in VC and Resource pools of all the clusters in VS-Farm. Seperate reports are required for VC and each resouce pool in the cluster.
Report should consist of the following properties.
VM Name, Power State, Status, Host, Provisioned Space, Used Space, Host CPU - MHz, Host Mem - MB, Guest Mem - %, Notes, Alarm Actions.
Thanks in Advance.
Ok, got it.
I have updated the first reply
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not sure what you with the "Alarm Actions" ?
I'm also not sure what type of report you want. On screen, in a CSV ...?
This is a sample, where there will be a sparate CSV file per resource pool.
Notice that the default resource pool will have "Resources" for it's name.
$Report = @() foreach($cluster in (Get-Cluster)){ foreach($respool in ($cluster | Get-ResourcePool)){ foreach($vmImpl in ($respool | Get-VM)){ $vm = $vmImpl | Get-View $row = "" | Select Cluster, "Resource Pool","VM Name", "Power State", Status, Host, "Provisioned Space - GB", "Used Space - GB", "Host CPU - MHz", "Host Mem - MB", "Guest Mem - %", Notes, "Alarm Actions" $row.Cluster = $cluster.Name $row."Resource Pool" = $respool.Name $row."VM Name" = $vmImpl.Name $row."Power State" = $vmImpl.PowerState $row.Status = ($vmImpl | Get-VMGuest).State $row.Host = $vmImpl.Host.Name $row."Provisioned Space - GB" = "{0:f2}" -f (($vm.Summary.Storage.Committed + $vm.Summary.Storage.Uncommitted)/1GB) $row."Used Space - GB" = "{0:f2}" -f ($vm.Summary.Storage.Committed/1GB) $row."Host CPU - MHz" = $vm.Summary.QuickStats.OverallCpuUsage $row."Host Mem - MB" = $vm.Summary.QuickStats.HostMemoryUsage $row."Guest Mem - %" = "{0:p0}" -f ($vm.Summary.QuickStats.GuestMemoryUsage/1MB/$vm.Config.Hardware.MemoryMB) $row.Notes = $vmImpl.Notes $row."Alarm Actions" = &{if($vm.AlarmActionsEnabled){"Enabled"}else{"Disabled"}} $report += $row } } } $groups = $report | Group-Object -Property Cluster,"Resource Pool" $groups | %{ $_.Group | Export-Csv ("C:\" + $_.Values[0] + "-" + $_.Values[1] + ".csv") -NoTypeInformation }
Since there are square brackets in the script and since the forum SW doesn't like square brackets, I attched the script.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We usually do this reporting manually by listing all the VM's in the VC and exporting the list to Excel. By default all these properties are listed.
Ok, got it.
I have updated the first reply
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD. This is not generating reports at the VC level. i.e., List of all the VM's in VC.
Your help is much apperciated.
Thanks in advance.
The VC report is just adding a single line to the script, like this
$Report = @() foreach($cluster in (Get-Cluster)){ foreach($respool in ($cluster | Get-ResourcePool)){ foreach($vmImpl in ($respool | Get-VM)){ $vm = $vmImpl | Get-View $row = "" | Select Cluster, "Resource Pool","VM Name", "Power State", Status, Host, "Provisioned Space - GB", "Used Space - GB", "Host CPU - MHz", "Host Mem - MB", "Guest Mem - %", Notes, "Alarm Actions" $row.Cluster = $cluster.Name $row."Resource Pool" = $respool.Name $row."VM Name" = $vmImpl.Name $row."Power State" = $vmImpl.PowerState $row.Status = ($vmImpl | Get-VMGuest).State $row.Host = $vmImpl.Host.Name $row."Provisioned Space - GB" = "{0:f2}" -f (($vm.Summary.Storage.Committed + $vm.Summary.Storage.Uncommitted)/1GB) $row."Used Space - GB" = "{0:f2}" -f ($vm.Summary.Storage.Committed/1GB) $row."Host CPU - MHz" = $vm.Summary.QuickStats.OverallCpuUsage $row."Host Mem - MB" = $vm.Summary.QuickStats.HostMemoryUsage $row."Guest Mem - %" = "{0:p0}" -f ($vm.Summary.QuickStats.GuestMemoryUsage/1MB/$vm.Config.Hardware.MemoryMB) $row.Notes = $vmImpl.Notes $row."Alarm Actions" = &{if($vm.AlarmActionsEnabled){"Enabled"}else{"Disabled"}} $report += $row } } } $report | Export-Csv ("C:\" + $defaultVIServer.Name + ".csv") -NoTypeInformation $groups = $report | Group-Object -Property Cluster,"Resource Pool" $groups | %{ $_.Group | Export-Csv ("C:\" + $_.Values[0] + "-" + $_.Values[1] + ".csv") -NoTypeInformation }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
HI
How do I do to use this PowerCli script? Just paste it in the commanline?
/T
That is one possibility, but there are easier ways.
PowerCLI C:> ./script.ps1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi
How and where do I edit the "ExecutionPolicy"?
/T
Use
Get-ExecutionPolicy
to see what is configured. And use
Set-ExecutionPolicy RemoteSigned
to change the setting.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
where can I find a powercli for vsphere to use for the scripts?
/T.
There is a download link here
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
I´ve downloaded powercli for vmware, but when I run the script file I get this error "File C:\temp\CLuster-respool-vm-report.ps1 cannot be loaded. The file C:\temp\CLuster-respool-vm-report.ps1 is not digitally signed." How do I do to get around this?
/T.
You will have to set the PowerShell execution policy.
Do
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for all the help it
is very appreciated. Do
you know how or do you
know where I can find I a
script which can generate
a report with following
output?
cpu - number and performance status
Mem - sized and performance status
Disk1 - size and used
Disk2 - size and used
Disk3 - size and used etc.
Nic 1
Nic 2 etc.
VmWare tool version
VmWare hw version
/T