From e0a31e69cbfa8a6bb2fcba54ed3f0cc979b520f5 Mon Sep 17 00:00:00 2001 From: onerstam <75037984+onerstam@users.noreply.github.com> Date: Fri, 27 Aug 2021 17:54:21 +0200 Subject: [PATCH] Remove breaks in Get-MSIntuneAuthToken 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. --- Modules/PSIntuneAuth/PSIntuneAuth.psm1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/PSIntuneAuth/PSIntuneAuth.psm1 b/Modules/PSIntuneAuth/PSIntuneAuth.psm1 index 560d40c..9de39c6 100644 --- a/Modules/PSIntuneAuth/PSIntuneAuth.psm1 +++ b/Modules/PSIntuneAuth/PSIntuneAuth.psm1 @@ -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)"; } } } @@ -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 } -} \ No newline at end of file +}