After rebuildning our network at my work I had to change VLAN on some Virtual Machines. Instead of doing it manually I wrote a simple PowerCLI script that changes the VLAN on all VMs in a specific folder.
#Vlan change for VMs
#Config variables
$folder = "the folder you store the specific VMS in"
$vlan = "thenameofthevlan in vSpheere, like clients"
#Gets VMs from folders and select the name of the VM
$vms = get-folder $folder | Get-VM | Select-object Name
#Loops thru every VM, get the network adapater and set the new VLAN
foreach($vms in $vms)
{
Get-NetworkAdapter -VM $vms.Name | Set-NetworkAdapter -Networkname $vlan -Confirm:$false
}
Recent Comments