Monthly Archives: January 2021

vmware powercli commands

Add Network Port Group

To add to all hosts in the cluster, use this script:

get-cluster "My-Servers" | Get-VMHost | Get-VirtualSwitch -Name "vSwitch0" | New-VirtualPortGroup -Name "VM Mgmt Network VLAN 101" -VLanId 101

To add to one host, use this script:

get-vmhost "IP of Host" | Get-VirtualSwitch -Name "vSwitch0" | New-VirtualPortGroup -Name "VM Mgmt Network VLAN 101" -VLanId 101

Remove port group from all hosts:

Get-VMHost | Get-VirtualPortGroup -Name "VM Mgmt Network VLAN 101" | Remove-VirtualPortGroup