Skip to content

Commit bebccd9

Browse files
authored
Merge pull request #311 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents b370415 + ea55af6 commit bebccd9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function Get-CIPPAlertGlobalAdminNoAltEmail {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
try {
14+
# Get all Global Admin accounts using the role template ID
15+
$globalAdmins = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/directoryRoles/roleTemplateId=62e90394-69f5-4237-9190-012177145e10/members?`$select=id,displayName,userPrincipalName,otherMails" -tenantid $($TenantFilter) -AsApp $true | Where-Object {
16+
$_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' -and $_.'@odata.type' -eq '#microsoft.graph.user'
17+
}
18+
19+
# Filter for Global Admins without alternate email addresses
20+
$adminsWithoutAltEmail = $globalAdmins | Where-Object {
21+
$null -eq $_.otherMails -or $_.otherMails.Count -eq 0
22+
}
23+
24+
if ($adminsWithoutAltEmail.Count -gt 0) {
25+
$AlertData = "The following Global Admin accounts do not have an alternate email address set: $($adminsWithoutAltEmail.userPrincipalName -join ', ')"
26+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
27+
}
28+
} catch {
29+
Write-LogMessage -message "Failed to check alternate email status for Global Admins: $($_.exception.message)" -API 'Global Admin Alt Email Alerts' -tenant $TenantFilter -sev Error
30+
}
31+
}

0 commit comments

Comments
 (0)