PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
Get-VMCSDDC doesn't handle SDDC names with special characters
Quoted SDDC Name w/o character escape:
> Connect-NSXTProxy -RefreshToken XXXXX -OrgName"M5 EA - MYORG(Free!)"-SDDCName"ORG-VMC-VA-EA-M5"
A server error occurred: 'com.vmware.vapi.std.errors.unauthorized': . Check $Error[0].Exception.ServerError for more details.
At /Users/User/Powershell/VMware.VMC.NSXT.psm1:31 char:9
+ $sddc = $sddcService.get($orgId,$sddcId)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException
This is not an NSX-T based SDDC
==
Quoted SDDC Name with character escape:
> Connect-NSXTProxy-RefreshToken XXXXXXXX -OrgName"M5 EA - MYORG \(Free\!\)"-SDDCName"ORG-VMC-VA-EA-M5"
headers Server ------- ------ {Accept, Content-Type, csp-auth-token} https://nsx-XXXXX.rp.vmwarevmc.com/vmc/reverse-proxy/api/orgs/XXX/sddcs/5XXXX
Did you try single quotes?
Hi Alan,
No luck. Also, the error message is a bit confusing.
> Connect-NSXTProxy -RefreshToken XXXXX -OrgName 'M5 EA - ORG(Free!)' -SDDCName ORG-VMC-VA-EA-M5
A server error occurred: 'com.vmware.vapi.std.errors.unauthorized': . Check $Error[0].Exception.ServerError for more details.
At /Users/USER/Powershell/VMware.VMC.NSXT.psm1:31 char:9
+ $sddc = $sddcService.get($orgId,$sddcId)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException
This is not an NSX-T based SDDC](url)
And your using the refresh token from that Org right? The error is unauthorized.
Hi Alan,
That's correct, I have a Refresh Token for the proper org, and the error doesn't show up, within the same powercli session, if I repeat the command but with the open and close parens and bang escaped in the SDDC name.
It appears that the unauthorized error is spurious in this case.
Here's an example, in the same session, using the Get-VMCSDDC commandlet directly...
PS /Users/USER> Connect-VmcServer -RefreshToken XXXX
Server User
------ ----
vmc.vmware.com [email protected]
PS /Users/USER> Get-VMCSDDC
cmdlet Get-VMCSDDC at command pipeline position 1
Supply values for the following parameters:
Org: M5 EA - ORG \(Free\!\)
Help : @{Documentation=; updated=; user_id=;
updated_by_user_id=; created=; version=;
updated_by_user_name=; user_name=; id=; name=;
sddc_state=; expiration_date=; org_id=; sddc_type=;
provider=; account_link_state=; resource_config=}
user_id : XXXXX
user_name : XXXXX
created : 9/11/18 6:10:28 PM
version : 44
id : XXXXX
updated_by_user_id : XXXXX
updated_by_user_name : [email protected]
updated : 9/19/18 7:30:45 PM
name : ORG-VMC-VA-EA-M5
provider : AWS
... Compared to not being able to find the SDDC name at all if I use single or double quotes (no escaped characters)
PS /Users/USER> Get-VMCSDDC
cmdlet Get-VMCSDDC at command pipeline position 1
Supply values for the following parameters:
Org: 'M5 EA - ORG(Free!)'
// No return data
PS /Users/USER> Get-VMCSDDC
cmdlet Get-VMCSDDC at command pipeline position 1
Supply values for the following parameters:
Org: "M5 EA - ORG(Free!)"
// No return data
Thanks Nathan, will check it out