Skip to content

Commit 7db8767

Browse files
committed
Update Invoke-CIPPStandardPerUserMFA.ps1
1 parent 3c2022d commit 7db8767

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardPerUserMFA.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ function Invoke-CIPPStandardPerUserMFA {
3939
url = "/users/$id/authentication/requirements"
4040
}
4141
}
42-
$UsersWithoutMFA = (New-GraphBulkRequest -tenantid $tenant -Requests @($Requests) -asapp $true).body | Where-Object { $_.perUserMfaState -ne 'enforced' } | Select-Object peruserMFAState, @{Name = 'userPrincipalName'; Expression = { [System.Web.HttpUtility]::UrlDecode($_.'@odata.context'.split("'")[1]) } }
42+
if ($Requests) {
43+
$UsersWithoutMFA = (New-GraphBulkRequest -tenantid $tenant -Requests @($Requests) -asapp $true).body | Where-Object { $_.perUserMfaState -ne 'enforced' } | Select-Object peruserMFAState, @{Name = 'userPrincipalName'; Expression = { [System.Web.HttpUtility]::UrlDecode($_.'@odata.context'.split("'")[1]) } }
44+
} else {
45+
$UsersWithoutMFA = @()
46+
}
4347

4448
If ($Settings.remediate -eq $true) {
45-
if (($UsersWithoutMFA.userPrincipalName | Measure-Object).Count -gt 0) {
49+
if (($UsersWithoutMFA | Measure-Object).Count -gt 0) {
4650
try {
4751
$MFAMessage = Set-CIPPPerUserMFA -TenantFilter $Tenant -userId @($UsersWithoutMFA.userPrincipalName) -State 'enforced'
4852
Write-LogMessage -API 'Standards' -tenant $tenant -message $MFAMessage -sev Info

0 commit comments

Comments
 (0)