VMware Cloud Community
brandong08
Enthusiast
Enthusiast

Help with Script for NIC to Start Connected

I had on VM in my environment that was not set to start connected for some reason.  So I wanted to write a script that would go through 500+ VM's and set the NIC to start connected.

I took a script that changed the Syslog server, which I had used successfully in the past.  I tried to change it up, but was unsuccessful.  Can someone take a look at this script and tell me what im doing wrong?

Thanks!

$StartConnected =$true

Get-VM | Foreach {

Write-Host “Adding $StartConnected connection state of NIC $($_.Name)”

$SetNetworkAdapter = Set-NetworkAdapter -StartConnected $StartConnected -VM $_

Write-Host “Setting NIC $($_.Name)”

}

2 Replies
LucD
Leadership
Leadership

Try like this

Get-VM | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected:$true -Confirm:$false


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

brandong08
Enthusiast
Enthusiast

That worked.  Thanks for the help.

Reply
0 Kudos