Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

New-NSXController throws an API error when a ControllerName is supplied #468

Closed
sammcgeown opened this issue Feb 7, 2018 · 1 comment
Closed

Comments

@sammcgeown
Copy link
Contributor

If you supply a ControllerName input for New-NSXController, the code adds a duplicate entry to the XML, which then throws an error when sent to the API.

In the code below, the "name" element is defined twice if ControllerName is defined. Removing the first if clause (line 7619) fixes the issue, since $ControllerName is populated in the begin if it's not supplied.

 # Check for presence of optional controller name
        if ($PSBoundParameters.ContainsKey("ControllerName")) {Add-XmlElement -xmlRoot $ControllerSpec -xmlElementName "name" -xmlElementText $ControllerName.ToString()}
        if ($PSBoundParameters.ContainsKey("Password") -and ($Ctrlcount.count -eq 0)) {Add-XmlElement -xmlRoot $ControllerSpec -xmlElementName "password" -xmlElementText $Password.ToString()}
        Add-XmlElement -xmlRoot $ControllerSpec -xmlElementName "datastoreId" -xmlElementText $DataStore.ExtensionData.Moref.value.ToString()
        Add-XmlElement -xmlRoot $ControllerSpec -xmlElementName "networkId" -xmlElementText $PortGroup.ExtensionData.Moref.Value.ToString()
        Add-XmlElement -xmlRoot $ControllerSpec -xmlElementName "name" -xmlElementText $ControllerName
@sammcgeown sammcgeown mentioned this issue Feb 7, 2018
@nmbradford
Copy link
Contributor

Thanks @sammcgeown ! Just hit one of these myself !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants