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

Commit

Permalink
cliSettings Always check there is XML node before change value
Browse files Browse the repository at this point in the history
  • Loading branch information
alagoutte committed Jan 28, 2018
1 parent 8beda2f commit 97bc7a5
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions module/PowerNSX.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -14145,22 +14145,42 @@ function Set-NsxcliSettings {
#If the user did not specify a given parameter, we dont want to modify from the existing value.

if ( $PsBoundParameters.ContainsKey('userName') ) {
$_cliSettings.username = $userName
if ( invoke-xpathquery -node $_cliSettings -querymethod SelectSingleNode -Query "child::userName" ) {
$_cliSettings.username = $userName
} else {
Add-XmlElement -xmlroot $_cliSettings -xmlElementName "userName" -xmlElementText $userName
}
}

#You need ALWAYS to specified the password...
Add-XmlElement -xmlRoot $_cliSettings -xmlElementName "password" -xmlElementText $password
if ( invoke-xpathquery -node $_cliSettings -querymethod SelectSingleNode -Query "child::password" ) {
$_cliSettings.password = $password
} else {
Add-XmlElement -xmlRoot $_cliSettings -xmlElementName "password" -xmlElementText $password
}

if ( $PsBoundParameters.ContainsKey('remoteAccess') ) {
if ( invoke-xpathquery -node $_cliSettings -querymethod SelectSingleNode -Query "child::remoteAccess" ) {
$_cliSettings.remoteAccess = $remoteAccess.ToString().ToLower()
} else {
Add-XmlElement -xmlroot $_cliSettings -xmlElementName "remoteAccess" -xmlElementText $remoteAccess.ToString().ToLower()
}
}

if ( $PsBoundParameters.ContainsKey('passwordExpiry') ) {
$_cliSettings.passwordExpiry = $passwordExpiry
if ( invoke-xpathquery -node $_cliSettings -querymethod SelectSingleNode -Query "child::passwordExpiry" ) {
$_cliSettings.passwordExpiry = $passwordExpiry
} else {
Add-XmlElement -xmlroot $_cliSettings -xmlElementName "passwordExpiry" -xmlElementText $passwordExpiry
}
}

if ( $PsBoundParameters.ContainsKey('sshLoginBannerText') ) {
$_cliSettings.sshLoginBannerText = $sshLoginBannerText
if ( invoke-xpathquery -node $_cliSettings -querymethod SelectSingleNode -Query "child::sshLoginBannerText" ) {
$_cliSettings.sshLoginBannerText = $sshLoginBannerText
} else {
Add-XmlElement -xmlroot $_cliSettings -xmlElementName "sshLoginBannerText" -xmlElementText $sshLoginBannerText
}
}

$URI = "/api/4.0/edges/$($EdgeId)/clisettings"
Expand Down

0 comments on commit 97bc7a5

Please sign in to comment.