The Multifunctioning DBA

Apr 30 2010   6:00PM GMT

VMWare and Powershell

Colin Smith Colin Smith Profile: Colin Smith

The other day I was asked to put a script together to disable all the backup nics that we have installed on a set of Virtual machines. This was cool for me as I had not done anything with VMWare in Powershell. I went out and downloaded the VMWare Powershell tools and I was on my way. Here is what I did and this disabled any NIC with a name like bak on a set of servers that I was able to filter by a common name string.

 

 

 

 

$machines

 

 

= Get-VM name*

 

 

 

foreach

($machine in $machines){

 

 

$bak = Get-NetworkAdapter -VM $machine | where{$_.networkname -like “*bak*”} } 

 

 

Set-NetworkAdapter -NetworkAdapter $bak -Connected $false Confirm:$false }

That is it. It went out got all machines with a name like “name* and disabled the NIC that had a name like “*bak*”. Easy and way faster than manually making the changes.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: