Skip to content

Commit

Permalink
Remove breaks in Get-MSIntuneAuthToken
Browse files Browse the repository at this point in the history
Break statement exits execution also for callers and there is no way for a caller to handle warning in a script because it is exited.
  • Loading branch information
onerstam authored Aug 27, 2021
1 parent bb96430 commit e0a31e6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Modules/PSIntuneAuth/PSIntuneAuth.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,27 @@ function Get-MSIntuneAuthToken {
return $Authentication
}
else {
Write-Warning -Message "Failure to acquire access token. Response with access token was null"; break
Write-Warning -Message "Failure to acquire access token. Response with access token was null";
}
}
catch [System.Exception] {
Write-Warning -Message "An error occurred when attempting to call AcquireTokenAsync method. Error message: $($_.Exception.Message)"; break
Write-Warning -Message "An error occurred when attempting to call AcquireTokenAsync method. Error message: $($_.Exception.Message)";
}
}
catch [System.Exception] {
Write-Warning -Message "An error occurred when constructing an authentication token. Error message: $($_.Exception.Message)"; break
Write-Warning -Message "An error occurred when constructing an authentication token. Error message: $($_.Exception.Message)";
}
}
catch [System.Exception] {
Write-Warning -Message "Unable to load required assemblies from AzureAD module to construct an authentication token. Error message: $($_.Exception.Message)"; break
Write-Warning -Message "Unable to load required assemblies from AzureAD module to construct an authentication token. Error message: $($_.Exception.Message)";
}
}
else {
Write-Warning -Message "Azure AD PowerShell module is not present on this system, please install before you continue"; break
Write-Warning -Message "Azure AD PowerShell module is not present on this system, please install before you continue";
}
}
catch [System.Exception] {
Write-Warning -Message "Unable to load required AzureAD module to for retrieving an authentication token. Error message: $($_.Exception.Message)"; break
Write-Warning -Message "Unable to load required AzureAD module to for retrieving an authentication token. Error message: $($_.Exception.Message)";
}
}
}
Expand Down Expand Up @@ -371,4 +371,4 @@ function Set-MSIntuneAdminConsent {
catch [System.Exception] {
Write-Warning -Message "Unable to load required assemblies (Azure AD PowerShell module) to construct an authentication token. Error: $($_.Exception.Message)" ; break
}
}
}

0 comments on commit e0a31e6

Please sign in to comment.