VMware Cloud Community
chuckado
Contributor
Contributor
Jump to solution

Searching for specific network adapters

I am looking to search for specific network adapters within our infrastructure.  I have been using this command.

$vms = get-vm ; foreach ($vm in $vms) {write-host $vm.Name "-" $vm.networkadapters[0].type }

I would like to filter this to look for the flexible network adapter.  After all of the network adapters have been found, we are looking to find an automated way to change all of the flexible drivers.  If anyone can help me with filtering out the flexible drivers, it would be greatly appreciated.

Thanks

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The next PowerCLI script lists all the virtual machines with Flexible type network adapters:

Get-VM | Get-NetworkAdapter | Where-Object {
  $_.Type -eq "Flexible"} | `
  Select @{N="VM";E={$_.Parent}},@{N="Network Adapter";E={$_.Name}},Type

If you want to change the network adapter type for all the Flexible network adapters to Vmxnet3 you can do this with the next script:

Get-VM | Get-NetworkAdapter | Where-Object {
  $_.Type -eq "Flexible"} | `
  Set-NetworkAdapter -Type Vmxnet3 -Confirm:$false

 

Regards, Robert

Message was edited by: RvdNieuwendijk Added the second script

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
3 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The next PowerCLI script lists all the virtual machines with Flexible type network adapters:

Get-VM | Get-NetworkAdapter | Where-Object {
  $_.Type -eq "Flexible"} | `
  Select @{N="VM";E={$_.Parent}},@{N="Network Adapter";E={$_.Name}},Type

If you want to change the network adapter type for all the Flexible network adapters to Vmxnet3 you can do this with the next script:

Get-VM | Get-NetworkAdapter | Where-Object {
  $_.Type -eq "Flexible"} | `
  Set-NetworkAdapter -Type Vmxnet3 -Confirm:$false

 

Regards, Robert

Message was edited by: RvdNieuwendijk Added the second script

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Warning, depending on the OS you run in the guest, it will recognise this NIC typechange as a new NIC.

As a consequence your IP settings will be gone


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

chuckado
Contributor
Contributor
Jump to solution

Thank you both very much the filter worked very well. 

0 Kudos