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
if ($MgAuthenticationModuleVersion-lt$MinimumVersion) {
79
+
## Check for newer module but load will likely fail due to old Microsoft.Graph.Authentication module
80
+
try {
81
+
Import-Module$ModuleName-MinimumVersion $MinimumVersion-Scope Global -ErrorAction Stop -Verbose:$false
82
+
}
83
+
catch [System.IO.FileLoadException] {
84
+
$result=$false
85
+
Write-Error-Exception $_.Exception-Category ResourceUnavailable -ErrorId 'MgModuleOutOfDate'-Message ("The module '{0}' with minimum version '{1}' was found but currently loaded 'Microsoft.Graph.Authentication' module is version '{2}'. To resolve, try opening a new PowerShell session and running the command again."-f$ModuleName,$MinimumVersion,$MgAuthenticationModuleVersion) -TargetObject $ModuleName-RecommendedAction ("Import-Module {0} -MinimumVersion '{1}'"-f$ModuleName,$MinimumVersion)
86
+
}
87
+
catch [System.IO.FileNotFoundException] {
88
+
$result=$false
89
+
Write-Error-Exception $_.Exception-Category ResourceUnavailable -ErrorId 'MgModuleWithVersionNotFound'-Message ("The module '{0}' with minimum version '{1}' not found. To resolve, try installing module '{0}' with the latest version. For example: Install-Module {0} -MinimumVersion '{1}'"-f$ModuleName,$MinimumVersion) -TargetObject $ModuleName-RecommendedAction ("Install-Module {0} -MinimumVersion '{1}'"-f$ModuleName,$MinimumVersion)
90
+
}
91
+
}
92
+
else {
93
+
## Load module to match currently loaded Microsoft.Graph.Authentication module
94
+
try {
95
+
Import-Module$ModuleName-RequiredVersion $MgAuthenticationModuleVersion-Scope Global -ErrorAction Stop -Verbose:$false
96
+
}
97
+
catch [System.IO.FileLoadException] {
98
+
$result=$false
99
+
Write-Error-Exception $_.Exception-Category ResourceUnavailable -ErrorId 'MgModuleOutOfDate'-Message ("The module '{0}' was found but is not a compatible version. To resolve, try updating module '{0}' to version '{1}' to match currently loaded modules. For example: Update-Module {0} -RequiredVersion '{1}'"-f$ModuleName,$MgAuthenticationModuleVersion) -TargetObject $ModuleName-RecommendedAction ("Update-Module {0} -RequiredVersion '{1}'"-f$ModuleName,$MgAuthenticationModuleVersion)
100
+
}
101
+
catch [System.IO.FileNotFoundException] {
102
+
$result=$false
103
+
Write-Error-Exception $_.Exception-Category ResourceUnavailable -ErrorId 'MgModuleWithVersionNotFound'-Message ("The module '{0}' with version '{1}' not found. To resolve, try installing module '{0}' with version '{1}' to match currently loaded modules. For example: Install-Module {0} -RequiredVersion '{1}'"-f$ModuleName,$MgAuthenticationModuleVersion) -TargetObject $ModuleName-RecommendedAction ("Install-Module {0} -RequiredVersion '{1}'"-f$ModuleName,$MgAuthenticationModuleVersion)
if ($MgCommand.Permissions-and (!$MgContext.Scopes-or!(Compare-Object$MgCommand.Permissions.Name-DifferenceObject $MgContext.Scopes-ExcludeDifferent -IncludeEqual))) {
122
+
$Exception=New-Object System.Security.SecurityException -ArgumentList "Additional scope required for command '$($MgCommand.Command)', call Connect-MgGraph with one of the following scopes: $($MgCommand.Permissions.Name-join', ')"
if ($MgCommand.Permissions-and (!$MgContext.Scopes-or!(Compare-Object$MgCommand.Permissions.Name-DifferenceObject $MgContext.Scopes-ExcludeDifferent -IncludeEqual))) {
132
+
Write-Warning"Additional scope may be required for command '$($MgCommand.Command), add and consent ClientId '$($MgContext.ClientId)' to one of the following app scopes: $($MgCommand.Permissions.Name-join', ')"
0 commit comments