File tree Expand file tree Collapse file tree
Modules/CIPPCore/Public/Alerts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,9 +13,25 @@ function Get-CIPPAlertNewAppApproval {
1313 $Headers
1414 )
1515 try {
16- $Approvals = New-GraphGetRequest - Uri " https://graph.microsoft.com/v1.0 /identityGovernance/appConsent/appConsentRequests?`$ filter=userConsentRequests/any (u:u/status eq 'InProgress')" - tenantid $TenantFilter
16+ $Approvals = New-GraphGetRequest - Uri " https://graph.microsoft.com/beta /identityGovernance/appConsent/appConsentRequests?`$ filter=userConsentRequests/any (u:u/status eq 'InProgress')" - tenantid $TenantFilter
1717 if ($Approvals.count -gt 0 ) {
18- $AlertData = " There are $ ( $Approvals.count ) App Approval(s) pending."
18+ $AlertData = [System.Collections.Generic.List [string ]]::new()
19+ foreach ($App in $Approvals ) {
20+ $userConsentRequests = New-GraphGetRequest - Uri " https://graph.microsoft.com/v1.0/identityGovernance/appConsent/appConsentRequests/$ ( $App.id ) /userConsentRequests" - tenantid $TenantFilter
21+ $userConsentRequests | ForEach-Object {
22+ $consentUrl = if ($App.consentType -eq ' Static' ) {
23+ # if something is going wrong here you've probably stumbled on a fourth variation - rvdwegen
24+ " https://login.microsoftonline.com/$ ( $TenantFilter ) /adminConsent?client_id=$ ( $App.appId ) &bf_id=$ ( $App.id ) &redirect_uri=https://entra.microsoft.com/TokenAuthorize"
25+ } elseif ($App.pendingScopes.displayName ) {
26+ " https://login.microsoftonline.com/$ ( $TenantFilter ) /v2.0/adminConsent?client_id=$ ( $App.appId ) &scope=$ ( $App.pendingScopes.displayName -Join (' ' )) &bf_id=$ ( $App.id ) &redirect_uri=https://entra.microsoft.com/TokenAuthorize"
27+ } else {
28+ " https://login.microsoftonline.com/$ ( $TenantFilter ) /adminConsent?client_id=$ ( $App.appId ) &bf_id=$ ( $App.id ) &redirect_uri=https://entra.microsoft.com/TokenAuthorize"
29+ }
30+
31+ $Message = " App name: $ ( $App.appDisplayName ) - Request user: $ ( $_.createdBy.user.userPrincipalName ) - Reason: $ ( $_.reason ) `n App Id: $ ( $App.appId ) - Scopes: $ ( $App.pendingScopes.displayName ) `n Consent URL: $consentUrl "
32+ $AlertData.Add ($Message )
33+ }
34+ }
1935 Write-AlertTrace - cmdletName $MyInvocation.MyCommand - tenantFilter $TenantFilter - data $AlertData
2036 }
2137 } catch {
You can’t perform that action at this time.
0 commit comments