maester
maester copied to clipboard
Enhance emergency access logic
Enhance emergency access logic
- Specify the emergency access account upn or group (by id/by upn/by group name)
- Exclude a certain policy (by name/by id)
Added emergency account detection to function Get-MTUser
If no users or groups are excluded from any conditional access, the MT.1005 test will automatically detect every user and group in the tenant, as the variable $ExcludedUserObjectGUID and $ExcludedGroupObjectGUID are empty, thus no value is assigned to $CheckId
$CheckId = $ExcludedGroupObjectGUID
$EmergencyAccessUUIDType = "group"
if ($ExcludedUsers -gt $ExcludedGroups) {
$EmergencyAccessUUIDType = "user"
$CheckId = $ExcludedUserObjectGUID
}
Which means that the following will query the Microsoft Graph "groups/" resource without an ID.
if ($EmergencyAccessUUIDType -eq "user") {
$DisplayName = Invoke-MtGraphRequest -RelativeUri "users/$CheckId" -Select displayName | Select-Object -ExpandProperty displayName
} else {
$DisplayName = Invoke-MtGraphRequest -RelativeUri "groups/$CheckId" -Select displayName | Select-Object -ExpandProperty displayName
}