VMware Cloud Community
vishal112
Contributor
Contributor
Jump to solution

Mass PowerCli command to disable a specific nic on 2000+ VMs ?

Hello.

Quick question

We are running

Esxi version 5.5U3 and Vsphere 5.5

We have 2000+ VM's that have a specific network adapter called VLANXXX  (Normal vswitch - not distributed)

It was used for our old backup system which was IP based and is now no longer required as we have moved to a snapshot based backup system.

I have got a extract of a list of all the VM'S with this adapter present in a csv / text format

eg

server1

server2

server3

is it possible to script a command to basically look at the file and then go ahead and "Disconnect nic VLANXXX " (Both on power on and current connected status) ?

Once its been disconnected and left like that for a week . the plan is to then run another script to remove that NIC completely from each VM.

I had a search around but was unable to find anything that could do this

Any suggestions would be great.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can try something like this

$pgName = 'VLANxx'

$vms = Get-VM -Name (Import-Csv names.csv -UseCulture)

Get-NetworkAdapter -VM $vms -| where{$_.NetworkName -eq $pgName} |

Set-NetworkAdapter -Connected:$false -StartConnected:$false -Confirm:$false


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

You can try something like this

$pgName = 'VLANxx'

$vms = Get-VM -Name (Import-Csv names.csv -UseCulture)

Get-NetworkAdapter -VM $vms -| where{$_.NetworkName -eq $pgName} |

Set-NetworkAdapter -Connected:$false -StartConnected:$false -Confirm:$false


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

0 Kudos