Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180923

PowerCLI to change VLANs for VMs

$
0
0

I am working on a script to change a couple of hundred VMs to a different VLAN.

 

The script is working in test EXCEPT, I am being prompt to confirm the change.  I have never been prompted before to confirm the change. One of the options is YES TO ALL however I want my script not to prompt at all, just make the change. 

 

Script:

 

 

# VCenter you are connecting too
$vcserver = "MyVcenter.somewhere.local"
Connect-VIServer $vcserver
# Loop to make changes to Network Adapter from List of Servers that needs to be changed
$serverlist = Get-Content "C:\Scripts\vlan_Test\vms.txt"
ForEach ($server in $serverlist)
{
$NIC = Get-NetworkAdapter -VM $server
Set-NetworkAdapter -NetworkAdapter $NIC -NetworkName "MyNewVLan 1234"
}

 

 

 

FYI: I am using PowerGUI to edit my PowerCLI scripts.

 

Thanks,

Boston Tech Guy


Viewing all articles
Browse latest Browse all 180923

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>