Skip to content

Commit 2d3a30c

Browse files
author
Rajat Agrawal
committed
Added warnings
1 parent 35f71bb commit 2d3a30c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Tasks/Common/VstsAzureHelpers_/InitializeFunctions.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,10 @@ function Disconnect-AzureAndClearContext {
652652
Write-Host "##[command]Logout-AzureRmAccount"
653653
Logout-AzureRmAccount
654654
}
655+
else {
656+
$noCommandMessage = "Unable to find a command to log out of Azure"
657+
Write-Host "##vso[task.logissue type=warning;]$noCommandMessage"
658+
}
655659

656660
if (Get-Command -Name "Clear-AzureRmContext" -ErrorAction "SilentlyContinue") {
657661
Write-Host "##[command]Clear-AzureRmContext -Scope Process"
@@ -660,6 +664,8 @@ function Disconnect-AzureAndClearContext {
660664
$null = Clear-AzureRmContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
661665
}
662666
} catch {
663-
Write-Verbose "Unable to disconnect and clear context: $_.Exception.Message"
667+
$error = $_.Exception.Message
668+
Write-Verbose "Unable to disconnect and clear context: $error"
669+
Write-Host "##vso[task.logissue type=warning;]$error"
664670
}
665671
}

0 commit comments

Comments
 (0)