You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
throw"Unable to find refresh token from Azure PowerShell Cache. Please try the command again in a fresh PowerShell instance after running 'Clear-AzureRmContext -Scope CurrentUser -Force -Verbose'."
448
+
}
449
+
}
450
+
440
451
return$refreshToken
441
452
}
442
453
@@ -802,7 +813,18 @@ function Unregister-AzsWithMyDirectoryTenant {
802
813
Sort ExpiresOn |
803
814
Select -Last 1-ExpandProperty RefreshToken |
804
815
ConvertTo-SecureString-AsPlainText -Force
805
-
816
+
817
+
# Workaround due to regression in AzurePowerShell profile module which fails to populate the response object of "Add-AzureRmAccount" cmdlet
818
+
if (-not$refreshToken) {
819
+
if ($tokens.Count-eq1) {
820
+
Write-Warning"Failed to find target refresh token from Azure PowerShell Cache; attempting to reuse the single cached auth context..."
throw"Unable to find refresh token from Azure PowerShell Cache. Please try the command again in a fresh PowerShell instance after running 'Clear-AzureRmContext -Scope CurrentUser -Force -Verbose'."
0 commit comments