Hi,
I am a complete amateur at scripting and new to PowerCLI. I am looking to export a list of all our virtual machines in our estate including the following values if possible:
Virtual Machine Name
Host the virtual machine is on
Notes
IP Address
regards,
Paul
Try this
Get-VM | select Name, Host, Description, @{N="IP"; E={$_ | Get-VMGuest | select -expandProperty IPAddress}}
Note: for the IP address you need to have the VMware Tools installed on the guest.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this
Get-VM | select Name, Host, Description, @{N="IP"; E={$_ | Get-VMGuest | select -expandProperty IPAddress}}
Note: for the IP address you need to have the VMware Tools installed on the guest.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm not sure about the IP address but the following script will do the VMHost, VM, and Notes.
Connect-VIServer -Server server
$VMs = Get-VMHost
$myCol = @()
foreach($vmhost in $VMs){
$myObj = "" | Select-Object Name, VM, Notes
$myObj.Name = $vmhost.Name
$VM = $vmhost | Get-VM
foreach($vmguest in $VM){
$myObj.VM = $vmguest.Name
$myObj.Notes = $vmguest.Description
}
$myCol += $myObj
}
$myCol | Export-Csv "C:\VM_Notes.csv" -NoTypeInformation
Josh Atwell
Thanks for that script it works perfectly! How would I tell it to output to an excel file?
Thanks,
Paul
True, but that won't work when a guest has more than 1 IP-address.
In that case the IP property will be an array which Export-Csv can't handle ![]()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
