PS 5.1 support and build pipeline updates

Updated some code for PS 5.1 version support with ZVMa as well as updated the azure-pipelines to build for zvma-updates branch
This commit is contained in:
2024-01-23 17:29:06 -05:00
parent 181761310c
commit 7f5237e53e
4 changed files with 34 additions and 15 deletions
@@ -123,18 +123,26 @@ public class TrustAllCertsPolicy : ICertificatePolicy {
}
# If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers as expected.
if ($uri -eq "auth/realms/zerto/protocol/openid-connect/token" -and $method -eq "POST") {
$submittedURI = "https://{0}:{1}/{2}" -f $script:zvmServer, $script:zvmPort, $uri
$body = @{
$data = @{
'client_id' = $script:zertoClientId
'username' = $credential.GetNetworkCredential().Username
'username' = $credential.GetNetworkCredential().UserName
'password' = $credential.GetNetworkCredential().Password
'grant_type' = 'password'
}
$contentType = 'application/x-www-form-urlencoded'
$apiRequestResults = Invoke-WebRequest -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100
#$responseHeaders = @{ }
#$responseHeaders['x-zerto-session'] = @($apiRequestResults.Headers['x-zerto-session'])
$params = @{
'Uri' = 'https://' + $script:zvmServer + ':' + $script:zvmPort + '/auth/realms/zerto/protocol/openid-connect/token'
'Method' = 'POST'
'Body' = $data
'ContentType' = 'application/x-www-form-urlencoded'
}
$apiRequestResults = Invoke-RestMethod @params
$ExpiresIn = $apiRequestResults.expires_in
$script:AuthExpiresAt = (Get-Date).AddSeconds($ExpiresIn)
$script:refreshToken = $apiRequestResults.refresh_token
$responseHeaders = @{ }
$responseHeaders['Authorization'] = "Bearer " + @($apiRequestResults.access_token)
} elseif ($method -ne "GET") {
# If the Method is something other than 'GET' use this call with a body parameter
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100