What would be the PowerCLI command to pull List of all of this info from a Virtual Machine? Just the Hardware Column and the Summary Column to make it simple.
I would like to be able to take the ESX name and have it automatically grab each individual Virtual Machines Properties and list them, that way I dont have to manually grab the VM names.
So I have the command and grabs all properties, Problem is the details arent all pulled. I know one particular ESX host has severals VMs of which all of them have ISOs connected. Also I'd like the Mapped RAW LUNS to also be specified under HardDisks.
$ESXhosts = "ESXhosts.txt"
Get-Content $ESXhosts | ForEach-Object {
(Get-VMhost $_ | Get-View).VM | % {$_ | Get-VIObjectByVIView}
}
What you are seeing are PowerShell's way of representing arrays (the [] in the value indicates that).
You have a number of options:
But I'm not sure how you got the result with the code you included?
That code doesn't seem to work for me.
Which PowerCLI version are you using?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Please see below. How would either add more loops and values, or join the values in a array using my current code?
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-PowerCLIVersion
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.5 Release 1 build 1295336
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.5 build 1262826
VMWare ImageBuilder PowerCLI Component 5.5 build 1262826
VMware vCloud Director PowerCLI Component 5.5 build 1295337
VMware License PowerCLI Component 5.5 build 1265954
VMware VDS PowerCLI Component 5.5 build 1295334
VMware vSphere PowerCLI Component 5.5 build 1295334
VMware vSphere Update Manager PowerCLI 6.0 build 2503190
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>
anyone have any ideas on this?
Or maybe just use the RVTools, it's free and does the job
thanks for the suggestion, but i am not looking to use RVTools.
Hi,
Not sure if this meets your requirements but you can use the Select-Object cmdlet with a pipe to to run nested cmdlets. Below is an example but essentially if you for example use Get-VM | Select @{Name="Whatever";Expression={ScriptBlock/cmdlet $_ | Select PropertyYouWant}}
Example provided below;
[string] $vCenter = "vc.example.com"
[string[]] $esxhosts = @("labesx1.example.tld,"labesx2.example.tld")
Connect-VIserver $vCenter
Get-VMHost $esxhosts | Get-VM | Select Name,NumCpu,MemoryGB, @{Name="CDDrives";Expression={Get-CDDrive $_ | Select IsoPath}},@{Name="HardDisk";Expression={Get-HardDisk $_ | Select Filename}},@{Name="FloppyDrives";Expression={Get-FloppyDrives $_ | Select FloppyImagePath}},@{Name="USBDevices";Expression={Get-UsbDevice}}
$objVMs | Export-CSV "D:\Temp\Example.csv" -NoTypeInformation
Hope this helps,
You still didn't show which properties and values you want to have in the output.
From the code you included in your initial entry, I can't derive that, since the code doesn't work.
The last reply with the Select cmdlet, doesn't work either.
The values will be garbled in case there are multiple entries (e.g. a VM with 2 harddisks)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference