Skip to content

Commit

Permalink
Merge pull request #2612 from sebassem/az-powershell-accessToken-brea…
Browse files Browse the repository at this point in the history
…king-change

add secureString flag to Get-AzAccessToken
  • Loading branch information
sebassem authored Jul 17, 2024
2 parents b36535a + 2c7842d commit af7848e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function registerArcForServers() {
elseif (Get-InstalledModule -Name Az.Accounts -MinimumVersion 2.2) {
# New versions of Az.Account support getting access tokens
#
$token = Get-AzAccessToken
$token = (Get-AzAccessToken -AsSecureString).token
$params += "--access-token"
$params += $token.Token
$params += (ConvertFrom-SecureString $token -AsPlainText)
}

& "$env:ProgramFiles\AzureConnectedMachineAgent\azcmagent.exe" $params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function registerArcForServers() {
elseif (Get-InstalledModule -Name Az.Accounts -MinimumVersion 2.2) {
# New versions of Az.Account support getting access tokens
#
$token = Get-AzAccessToken
$token = (Get-AzAccessToken -AsSecureString).token
$params += "--access-token"
$params += $token.Token
$params += (ConvertFrom-SecureString $token -AsPlainText)
}

& "$env:ProgramFiles\AzureConnectedMachineAgent\azcmagent.exe" $params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function registerArcForServers() {
elseif (Get-InstalledModule -Name Az.Accounts -MinimumVersion 2.2) {
# New versions of Az.Account support getting access tokens
#
$token = Get-AzAccessToken
$token = (Get-AzAccessToken -AsSecureString).token
$params += "--access-token"
$params += $token.Token
$params += (ConvertFrom-SecureString $token -AsPlainText)
}

& "$env:ProgramFiles\AzureConnectedMachineAgent\azcmagent.exe" $params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1466,14 +1466,14 @@ function Set-HCIDeployPrereqs {
Install-Module Az.Resources -Force
$azureAppCred = (New-Object System.Management.Automation.PSCredential $clientId, (ConvertTo-SecureString -String $clientSecret -AsPlainText -Force))
Connect-AzAccount -ServicePrincipal -SubscriptionId $subId -TenantId $tenantId -Credential $azureAppCred
$armtoken = Get-AzAccessToken
$armtoken = ConvertFrom-SecureString ((Get-AzAccessToken -AsSecureString).Token) -AsPlainText

# Workaround for BITS transfer issue
Get-NetAdapter StorageA | Disable-NetAdapter -Confirm:$false | Out-Null
Get-NetAdapter StorageB | Disable-NetAdapter -Confirm:$false | Out-Null

#Invoke the registration script.
Invoke-AzStackHciArcInitialization -SubscriptionID $subId -ResourceGroup $resourceGroup -TenantID $tenantId -Region $location -Cloud "AzureCloud" -ArmAccessToken $armtoken.Token -AccountID $clientId
Invoke-AzStackHciArcInitialization -SubscriptionID $subId -ResourceGroup $resourceGroup -TenantID $tenantId -Region $location -Cloud "AzureCloud" -ArmAccessToken $armtoken -AccountID $clientId

Get-NetAdapter StorageA | Enable-NetAdapter -Confirm:$false | Out-Null
Get-NetAdapter StorageB | Enable-NetAdapter -Confirm:$false | Out-Null
Expand Down

0 comments on commit af7848e

Please sign in to comment.