Skip to content

Commit

Permalink
Merge pull request #230 from sammcgeown/Update-Connect-vRAServer
Browse files Browse the repository at this point in the history
Update Connect-vRAServer
  • Loading branch information
jonathanmedd authored Jul 2, 2020
2 parents 7f38c1e + 0cf531f commit eaf0509
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/Functions/Public/Connect-vRAServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@
refreshToken = $APIToken
} | ConvertTo-Json
} else {
# -- Login with credentials
$URI = "https://$($Server)/csp/gateway/am/api/login?access_token"

# --- Convert Secure Credentials to a format for sending in the JSON payload
if ($PSBoundParameters.ContainsKey("Credential")){

Expand All @@ -163,11 +160,27 @@
throw "The Username format DOMAIN\Username is not supported by the vRA REST API. Please use username@domain instead"
}

# --- Create Invoke-RestMethod Parameters
$JSON = @{
username = $Username
password = $JSONPassword
} | ConvertTo-Json
# --- Logging in with a domain
if ($Username -match '@') {
# Log in using the advanced authentication API
$URI = "https://$($Server)/csp/gateway/am/idp/auth/login?access_token"
$User = $Username.split('@')[0]
$Domain = $Username.split('@')[1]
$JSON = @{
username = $User
password = $JSONPassword
domain = $Domain
} | ConvertTo-Json
} else {
# -- Login with the basic authentication API
$URI = "https://$($Server)/csp/gateway/am/api/login?access_token"

# --- Create Invoke-RestMethod Parameters
$JSON = @{
username = $Username
password = $JSONPassword
} | ConvertTo-Json
}
}


Expand Down

0 comments on commit eaf0509

Please sign in to comment.