VMC REST API - PowerSplitting

I’ve been working a lot recently on automating VMware Cloud on AWS. For Direct Connect and Route Based VPNs we needed to set the BGP ASN.

In the VMC console the Route Based VPN ASN is set under Networking & Security > VPN > Route Based > Edit Local ASN

Route Based VPN BGP ASN

For Direct Connect the setting is under Networking & Security > Direct Connect > BGP Local ASN

Route Based VPN BGP ASN

In code these can be changed but they are contained in different APIs.

For Direct Connect the setting is part of the VGW and can be changed with the NSX VMC AWS Integration API.

For Route Based VPNs the endpoint is the NSX T0 Edge Router and can be changed with the NSX VMC Policy API.

We can access either of these APIs through the NSX-T Proxy URL. This is what the proxy URL looks like. (I’ve anonymised the IP, Org Id and SDDC Id)


It can be used directly for the NSX VMC Policy API but for the NSX VMC AWS Integration API I found I need to strip the /sks-nsxt-manager route and replace it with /cloud-service/api/v1/infra/direct-connect/bgp.

PowerShell is our language of choice for this automation and on my development machine with PowerShell 6 I could use the .split method which gets me the URL I want plus a blank string.

PowerShell 6 split

But when this code is ran in the CI/CD pipeline it runs in PowerShell 5 and that was a problem.

PowerShell 5 split

There is a bit of a difference between a REST API endpoint of




This caused an awkward delay in getting some production SDDCs built.

I was baffled for a while but it was easy fix once I realized what was going. Rather than splitting on the entire string the .split method splits on each character. So it splits on / and on s and k on s etc.

Changing from .split to -split made the behaviour consistent across PowerShell 5 and 6.

PowerShell 6 -split PowerShell 5 -split

This explains how .split works better - https://devblogs.microsoft.com/scripting/powertip-know-the-difference-between-the-split-method-and-split/

Written on December 12, 2019