I’ve been toying with the vSphere Distributed Switch PowerCLI cmdlets off and on and have had mixed results. It’s worth noting it only works in 32-bit PowerShell, so if you’re wondering why you get do ‘get-vds’, it’s either because the snap-in is not there, or you’re in 64-bit PS. I have a vDS with 17 ‘Networks’, although one is the uplink, and the others are actual distributed port groups.  I added “Add-PSSnapin VMware.* -erroraction silentlycontinue” to my profile, so anytime I open PowerShell, I get all VMware snapins.

I was having difficulty because I was getting errors, things weren’t working as I expected, etc.  I’ll explain why…

When using something like Set-VdsDVPortTeamingPolicy, I tried adding –DVPortgroup with the actual name of the port group, like this:

And it would fail with Set-VdsDVPortTeamingPolicy : Cannot process argument transformation on parameter 'DVPortgroup'. Unexpected error occured. The string wrapper for type VMware.VimAutomation.VdsComponent.Types.V1.VdsDistributedPortgroup is not defined At line:1 char:40 + Set-VdsDVPortTeamingPolicy -DVPortgroup <<<< -LoadBalance "loadbalance_loadbased" -FailOverDetection "Beacon probing" + CategoryInfo : InvalidData: (:) [Set-VdsDVPortTeamingPolicy], ParameterBindin...mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,VMware.VimAutomation.VdsComponent.Commands.Cmdlets.SetVdsDVPortTeamingPolicy

Then, if I did a Get-VdsDistributedPortgroup and that port group would be listed.  I was starting to get frustrated because it seemed like the cmdlets were broken, when in fact it was that they expected the actual port group, and not the name.

With that, I did

and that worked fine.  I was missing the fact that I had to fill a variable with the port group, which makes sense.  Also is clear why the examples on the page I linked at the top use variables throughout.

With that, I wrote this:

That went through and set the load balancing and failover detection for every distributed port group.