PowerCLI

 View Only
Expand all | Collapse all

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

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

    Posted Oct 22, 2015 02:12 AM

    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.



  • 2.  RE: Mass PowerCli command to disable a specific nic on 2000+ VMs ?
    Best Answer

    Posted Oct 22, 2015 05:54 AM

    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