hello vmware experts,
I am new to VMware powercli, don't know how to use powercli to create report. manager asked me to created report in following formate in CSV format:
VMName | FolderName with full Path | PowerState | HostName | ClusterName | OSVersion | GuestIPAddress | ToolsStatus | NumCPU | RAMMB | DataStore1 | TotalDiskSize1 | DiskFree1 | DiskUsed1 | DataStore2 | TotalDiskSize2 | DiskFree2 | DiskUsed2 | and so on for Datastore and HardDrive |
will be very grateful if anyone have such a script and can share with me.
Regards,
Samir
You will find most of what you asked for here. Runtime is a bit long due to many demands
Hi vlife,
thanks for the reply, and sorry for the delay in reply as I was suffering from illness. I've tested script which you have provided but it's throwing following error and does not produce any .csv file
can you please let me know, how to resolve this error?
Thanks,
Sam
hi vlife201110141,
Script is running, but I am not getting the complete path of folder using this script. I am just getting the folder name.
can you please help me, how can I get the Full path of folder in Folder Column?
Thanks,
Sam
connect-viserver -server "xxx" -user "xxx" -password "xxx"
$report = @()
$vms = Get-View -ViewType "virtualmachine"
foreach($vm in $vms){
foreach($dev in $vm.Config.Hardware.Device){
if(($dev.gettype()).Name -eq "VirtualDisk"){
$row = "" | select VMName, FolderPath, PowerState, HostName, ClusterName, OSVersion, GuestIPAddress, ToolsStatus, NumCPU, MemoryMB, DeviceInfo, CapacityInGB, Datastore
$row.VMName = $vm.Name
$current = Get-View $vm.Parent
$path = $vm.Name
do {
$parent = $current
if($parent.Name -ne "vm"){$path = $parent.Name + "\" + $path}
$current = Get-View $current.Parent
} while ($current.Parent -ne $null)
$row.FolderPath = $path
$row.PowerState = $vm.runtime.powerstate
$row.HostName = (get-view -id $vm.runtime.host).name
$clu = (get-view -id $vm.Runtime.Host).parent
$row.ClusterName = (Get-View -id $clu).name
$row.OSVersion = $vm.summary.guest.guestfullname
$row.GuestIPAddress = $vm.guest.ipaddress
$row.ToolsStatus = $vm.guest.toolsstatus
$row.NumCPU = $vm.config.hardware.numcpu
$row.MemoryMB = $vm.config.hardware.MemoryMB
$row.DeviceInfo = $dev.deviceinfo.label
$row.CapacityInGB = [system.math]::Round($dev.CapacityInKB / 1048576)
$row.Datastore = $dev.backing.filename.split("]")[0].trim("[")
$report += $row
}
}
}
$report | Export-Csv C:\exportvms.csv -NoTypeInformation -UseCulture
Hi ,
creating VM report using powercli
I am not aware of POWERCLI but if want i can provide in perl scripting to report all those values