Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add per user MFA function #26

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<#
.SYNOPSIS
Retrieves the per-user Multi-Factor Authentication (MFA) status for a specified user or all users in a given customer tenant.

.PARAMETER CustomerTenantID
The ID of the customer tenant for which to retrieve the per-user MFA status. This parameter is mandatory.

.PARAMETER UserId
The ID of the user for whom to retrieve the per-user MFA status. This parameter is optional and is ignored if the AllUsers switch is specified.
Can be either the user's email address or the user's ID.

.PARAMETER AllUsers
A switch parameter that, when specified, retrieves the per-user MFA status for all users in the specified customer tenant. If this switch is specified, the UserId parameter is ignored.

.EXAMPLE
Get-CIPPPerUserMFA -CustomerTenantID "12345" -UserId "[email protected]"
Retrieves the per-user MFA status for the user with ID "[email protected]" in the customer tenant with ID "12345".

.EXAMPLE
Get-CIPPPerUserMFA -CustomerTenantID "12345" -AllUsers
Retrieves the per-user MFA status for all users in the customer tenant with ID "12345".

.NOTES
This function uses the Invoke-CIPPRestMethod cmdlet to make a GET request to the '/api/ListPerUserMFA' endpoint with the specified parameters.
#>
function Get-CIPPPerUserMFA {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $false)]
[string]$UserId,
[Parameter(Mandatory = $false)]
[switch]$AllUsers
)

if ($AllUsers.IsPresent -eq $true) {
Write-Verbose "Getting Per user MFA for all users in $CustomerTenantID"
} else {
Write-Verbose "Getting Per user MFA for $UserId in $CustomerTenantID"
}

$endpoint = '/api/ListPerUserMFA'
$params = @{
TenantFilter = $CustomerTenantID
userId = $UserId
allUsers = $AllUsers.IsPresent
}
Invoke-CIPPRestMethod -Endpoint $endpoint -Params $params -Method GET
}