In trying to get used to ESXi and it’s console-less nature I’ve been forcing myself to use the vCLI or PowerCLI to do things. Along the way I’ve learned that the vCLI is generally really well though out, if different. Here is an example of this: Setting up a vNetwork Standard Switch (vSwitch) using PowerCLI and the vCLI:
- Connect to the ESXi or vCenter server:
Get-Credential | Connect-VIServer –Server 126.96.36.199
- Create the new vSwitch:
Get-VMHost –Name “ESX Host” | New-VirtualSwitch –Name “NewSwitch”
A very basic example that, no uplinks and the like, but it does show that the action is very straight forward in PowerCLI.
This one is actually much much more complicated than the above (not really, but well…)
vicfg-vswitch.pl –add vSwitch1 –server 188.8.131.52 –username root –password yourP4ssword
There you go. Two one liners to add a vSwitch to your ESXi (or ESX) host. Both are simpler than I’d thought. Questions? Comments? Drop a line in the comments or hit me up on Twitter (@cody_bunch)
3 thoughts on “Add a vSwitch, PowerCLI vs. vCLI”
There's no reason to ever do -VMHost (Get-VMHost X) just say -VMHost X
My style of choice would say Get-VMHost X | New-VirtualSwitch …
You'd probably want to throw a -Nic in there somewhere as well.
Twas pulled from a larger script where the $vmhost) was used again. Post &
script have been updated accordingly.
thanks for your informative guidance.
Comments are closed.