VMware Cloud Community
BrianDGeorge
Enthusiast
Enthusiast
Jump to solution

PowerCLI change a result by removing Virtual

I have a VM inventory/status script and am collecting the vNIC property name but it keeps returning a response that I need but is not "pretty"  I want to remove the word Virtual from the results.

Get-View -ViewType VirtualMachine -Filter @{'Runtime.PowerState'='poweredOn'} |

Select Name,

@{N='Network Adapter';E={$_.Config.Hardware.Device  |  Where {$_ -is [VMware.Vim.VirtualEthernetCard]} | ForEach {$_.GetType().Name}}} | Out-GridView

I have tried every variation of remove, replace, etc... and still get "VirtualVmxnet3" and just want to see Vmxnet3.  I know that is picky but, go big or go home.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Does this help?

Get-View -ViewType VirtualMachine -Filter @{'Runtime.PowerState'='poweredOn'} |

Select Name,

@{N='Network Adapter';E={

    $_.Config.Hardware.Device  |  Where {$_ -is [VMware.Vim.VirtualEthernetCard]} |

ForEach {$_.GetType().Name.Replace('Virtual','')}}} | Out-GridView

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Does this help?

Get-View -ViewType VirtualMachine -Filter @{'Runtime.PowerState'='poweredOn'} |

Select Name,

@{N='Network Adapter';E={

    $_.Config.Hardware.Device  |  Where {$_ -is [VMware.Vim.VirtualEthernetCard]} |

ForEach {$_.GetType().Name.Replace('Virtual','')}}} | Out-GridView

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
BrianDGeorge
Enthusiast
Enthusiast
Jump to solution

Thank you LucD!! I was so close.  Getting back into the swing of managing the environment full time.

Reply
0 Kudos