Hello All,
Sorry to do this but I'm in kind of a hurry. I know I need to read the manual and I plan to do so very soon!!
I'm trying to build a table or create output that displays the VM name and the NetworkName. I don't know how to make the output show both. I put together the command below, but this only displays the NetworkName. I've tried various things, but I can't get both items to show up...
Can anyone help me out? Thanks!!!!
Get-Cluster DEV | Get-VM | Get-NetworkAdapter | Select-Object -Property 'NetworkName'
Try something like this
Get-Cluster DEV | Get-VM | Select Name, @{N="NIC";E={$_ | Get-NetworkAdapter | %{$_.NetworkName}}}
If you have more than 1 NIC on a VM, you can do
Get-Cluster DEV | Get-VM | Select Name, @{N="NIC";E={[string]::Join(',',($_ | Get-NetworkAdapter | %{$_.NetworkName}))}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-Cluster DEV | Get-VM | Select Name, @{N="NIC";E={$_ | Get-NetworkAdapter | %{$_.NetworkName}}}
If you have more than 1 NIC on a VM, you can do
Get-Cluster DEV | Get-VM | Select Name, @{N="NIC";E={[string]::Join(',',($_ | Get-NetworkAdapter | %{$_.NetworkName}))}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD- I'm getting this returned to me (using PowerGUI):
Missing '=' operator after key in hash literal. | At line: 4 char: 26 |
It's telling me there's something wrong around here "E{$"
My mistake, typo. It's corrected
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok, this only displays the VM names. Doesn't show the NetworkNames.
I think it's time I call it a day, another typo.
It's corrected now
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc. That works. Oddly it returns the right data from Powercli, but if I run it in PowerGUI I only get the VM names back. No NetworkNames.
Are you running the latest version of PowerGui ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yep- latest PowerGUI, and I just upgraded my PowerCLI too. Same result in PowerGUI. Only VM names.
Must be a PowerGui problem then.
I'll have to admit I'm not well versed in PowerGui, but perhaps you could raise the question in the PowerGui forum.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference