diff --git a/README.md b/README.md index b7abce5..88b6375 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ A call Graph refuses leaves those IDs as they are, with a warning that names the ## Personal data -Some output contains personal data (names, UPNs, email addresses, IP addresses, sign-in details): user details (`Get-InforcerUser -UserId`), audit events, report outputs, and the files written by `Export-InforcerTenantDocumentation`, `Compare-InforcerEnvironments`, `Invoke-InforcerAssessment`, `Invoke-InforcerReport` and `Save-InforcerReportOutput`. The module caches no user or audit data. It writes files only where you ask: to `-OutputPath`, or for `Invoke-InforcerReport` and `Save-InforcerReportOutput` to the current directory when `-OutputPath` is omitted (`-NoSave` writes nothing). Handle those files as personal data: keep them access-controlled and delete them when no longer needed. +Some output contains personal data (names, UPNs, email addresses, IP addresses, sign-in details): user details (`Get-InforcerUser -UserId`, including the phone numbers and email addresses in `-IncludeAuthenticationMethods` and the mailbox details in `-IncludeMailbox`), audit events, report outputs, and the files written by `Export-InforcerTenantDocumentation`, `Compare-InforcerEnvironments`, `Invoke-InforcerAssessment`, `Invoke-InforcerReport` and `Save-InforcerReportOutput`. The module caches no user or audit data. It writes files only where you ask: to `-OutputPath`, or for `Invoke-InforcerReport` and `Save-InforcerReportOutput` to the current directory when `-OutputPath` is omitted (`-NoSave` writes nothing). Handle those files as personal data: keep them access-controlled and delete them when no longer needed. ## Cmdlets @@ -178,13 +178,15 @@ Some output contains personal data (names, UPNs, email addresses, IP addresses, | **Connect-Inforcer** | Establishes a secure connection to the inforcer REST API with an API client (`-ClientId`/`-ClientSecret`, v1) or a legacy API key (`-ApiKey`, beta). Supports `-FetchGraphData` to also connect Microsoft Graph. | | **Disconnect-Inforcer** | Disconnects and clears the session (including Graph if connected). | | **Test-InforcerConnection** | Tests the API connection; returns `$true` or `$false`. | -| **Get-InforcerTenant** | Retrieves tenant information (optional filter by TenantId). | +| **Get-InforcerTenant** | Retrieves tenant information (optional filter by TenantId); `-IncludeSubscriptions` adds the tenant's licences with free seats (API client login only). | | **Get-InforcerBaseline** | Retrieves baseline groups and members. | | **Get-InforcerTenantPolicies** | Retrieves policies for a specified tenant. | | **Get-InforcerAlignmentDetails** | Retrieves alignment scores (table or raw format). | | **Get-InforcerAuditEvent** | Retrieves audit events (optional EventType, date range; -EventType has tab completion). | | **Get-InforcerSupportedEventType** | Returns the canonical list of audit event types accepted by `Get-InforcerAuditEvent -EventType`. Drives the tab completer; cached after first call. | -| **Get-InforcerUser** | Retrieves users from a tenant (list/search or detail by UserId). | +| **Get-InforcerUser** | Retrieves users from a tenant (list/search or detail by UserId); `-IncludeAuthenticationMethods` adds their sign-in methods and `-IncludeMailbox` their Exchange Online mailbox (API client login only). | +| **New-InforcerUser** | Creates a Microsoft Entra user in a tenant (API client login only). | +| **Set-InforcerUser** | Updates a user's profile, manager or sign-in, changes licences and group memberships, changes their mailbox (shared mailbox, online archive, automatic replies, forwarding, permissions, calendar sharing, mail groups, email addresses, inbox rules, mail apps, address lists), resets their password, removes sign-in methods or resets MFA, issues a Temporary Access Pass, or signs them out everywhere; only the fields you pass change (API client login only). | | **Get-InforcerGroup** | Retrieves Entra ID groups from a tenant (list/search or detail by GroupId). | | **Get-InforcerRole** | Retrieves Entra ID directory role definitions from a tenant. | | **Get-InforcerSecureScore** | Retrieves the current and 90-day historic Microsoft Secure Score for a tenant, including per-category scores and actionable control profiles. | diff --git a/Tests/Consistency.Tests.ps1 b/Tests/Consistency.Tests.ps1 index 6a75683..d13c11e 100644 --- a/Tests/Consistency.Tests.ps1 +++ b/Tests/Consistency.Tests.ps1 @@ -30,12 +30,12 @@ Describe 'Consistency contract' { $path = Get-InforcerCommunityManifestPath Import-Module $path -Force $script:exported = (Get-Module -Name 'InforcerCommunity').ExportedCommands.Keys - $script:expectedCount = 21 + $script:expectedCount = 23 $script:expectedNames = @( 'Connect-Inforcer', 'Disconnect-Inforcer', 'Test-InforcerConnection', 'Get-InforcerTenant', 'Get-InforcerBaseline', 'Get-InforcerTenantPolicies', 'Get-InforcerAlignmentDetails', 'Get-InforcerAuditEvent', 'Get-InforcerSupportedEventType', - 'Get-InforcerUser', 'Get-InforcerGroup', 'Get-InforcerRole', 'Get-InforcerSecureScore', + 'Get-InforcerUser', 'New-InforcerUser', 'Set-InforcerUser', 'Get-InforcerGroup', 'Get-InforcerRole', 'Get-InforcerSecureScore', 'Export-InforcerTenantDocumentation', 'Compare-InforcerEnvironments', 'Get-InforcerAssessment', 'Invoke-InforcerAssessment', 'Get-InforcerReportType', 'Invoke-InforcerReport', 'Get-InforcerReportRun', 'Save-InforcerReportOutput' @@ -44,13 +44,15 @@ Describe 'Consistency contract' { 'Connect-Inforcer' = @('ApiKey', 'ClientId', 'ClientSecret', 'Region', 'BaseUrl', 'FetchGraphData', 'PassThru') 'Disconnect-Inforcer' = @() 'Test-InforcerConnection' = @() - 'Get-InforcerTenant' = @('Format', 'TenantId', 'OutputType') + 'Get-InforcerTenant' = @('Format', 'TenantId', 'IncludeSubscriptions', 'OutputType') 'Get-InforcerBaseline' = @('Format', 'TenantId', 'OutputType') 'Get-InforcerTenantPolicies' = @('Format', 'TenantId', 'OutputType') 'Get-InforcerAlignmentDetails' = @('Format', 'TenantId', 'BaselineId', 'Tag', 'OutputType') 'Get-InforcerAuditEvent' = @('EventType', 'DateFrom', 'DateTo', 'User', 'PageSize', 'MaxResults', 'Format', 'OutputType') 'Get-InforcerSupportedEventType' = @() - 'Get-InforcerUser' = @('Format', 'TenantId', 'Search', 'MaxResults', 'UserId', 'OutputType') + 'Get-InforcerUser' = @('Format', 'TenantId', 'Search', 'MaxResults', 'UserId', 'IncludeAuthenticationMethods', 'IncludeMailbox', 'OutputType') + 'New-InforcerUser' = @('TenantId', 'DisplayName', 'UserPrincipalName', 'Password', 'MailNickname', 'AccountEnabled', 'ManagerId', 'UserType', 'OutputType') + 'Set-InforcerUser' = @('TenantId', 'UserId', 'AccountEnabled', 'DisplayName', 'ManagerId', 'UserType', 'Password', 'ForceChangePasswordNextSignIn', 'AddLicense', 'RemoveLicense', 'AddGroup', 'RemoveGroup', 'HiddenFromAddressLists', 'MailboxType', 'EnableArchive', 'AutoReply', 'ForwardTo', 'KeepForwardedCopy', 'RemoveForwarding', 'GrantMailboxPermission', 'RemoveMailboxPermission', 'GrantCalendarAccess', 'RemoveCalendarAccess', 'AddMailGroup', 'RemoveMailGroup', 'AddEmailAddress', 'PrimaryEmailAddress', 'RemoveEmailAddress', 'RemoveInboxRule', 'RemoveAllInboxRules', 'AllowMailApp', 'BlockMailApp', 'RemoveAuthenticationMethod', 'ResetMfa', 'TemporaryAccessPass', 'TemporaryAccessPassLifetime', 'TemporaryAccessPassUsableOnce', 'RevokeSessions') 'Get-InforcerGroup' = @('TenantId', 'Search', 'Filter', 'MaxResults', 'Group', 'OutputType') 'Get-InforcerRole' = @('TenantId', 'OutputType') 'Get-InforcerSecureScore' = @('TenantId', 'OutputType') diff --git a/Tests/V1.Tenants.Tests.ps1 b/Tests/V1.Tenants.Tests.ps1 index 3ae351f..de00fc9 100644 --- a/Tests/V1.Tenants.Tests.ps1 +++ b/Tests/V1.Tenants.Tests.ps1 @@ -273,6 +273,43 @@ Describe 'Get-InforcerBaseline' { } } +Describe 'Get-InforcerTenant -IncludeSubscriptions' { + BeforeEach { + Reset-V1TenantsRoutes + $global:V1TenantsRoutes['/v1/tenants/00000000-0000-0000-0000-000000000001/subscriptions$'] = '{"subscriptions":[{"skuId":"00000000-0000-0000-0000-0000000000c1","sku":"SPE_E5","name":"Microsoft 365 E5","capabilityStatus":"enabled","appliesTo":"user","units":{"enabled":25,"consumed":20,"available":5,"suspended":0,"warning":0,"lockedOut":0}}]}' + $global:V1TenantsRoutes['/v1/tenants/00000000-0000-0000-0000-000000000002/subscriptions$'] = @{ Status = 409; Body = '{"title":"Conflict","status":409}' } + Mock -ModuleName InforcerCommunity Invoke-InforcerHttpRequest { Get-V1TenantsResponse $Request.Uri } + } + + It 'v1: adds the subscriptions with skuId and seats, in both output types' { + Set-V1TenantsSession + $t = Get-InforcerTenant -TenantId $script:T1 -IncludeSubscriptions + $t.subscriptions.Count | Should -Be 1 + $t.subscriptions[0].skuId | Should -Be '00000000-0000-0000-0000-0000000000c1' + $t.subscriptions[0].units.available | Should -Be 5 + $json = Get-InforcerTenant -TenantId $script:T1 -IncludeSubscriptions -OutputType JsonObject | ConvertFrom-Json -Depth 100 + $json[0].subscriptions[0].sku | Should -Be 'SPE_E5' + } + + It 'v1: one request per tenant; a tenant whose subscriptions fail still comes back, with the error; the cached list is not changed' { + Set-V1TenantsSession + $out = @(Get-InforcerTenant -IncludeSubscriptions -ErrorAction SilentlyContinue -ErrorVariable e) + $out.Count | Should -Be 2 + $out[0].subscriptions.Count | Should -Be 1 + $out[1].PSObject.Properties['subscriptions'] | Should -BeNullOrEmpty + "$($e[-1])" | Should -BeLike '*409*' + Should -Invoke -ModuleName InforcerCommunity Invoke-InforcerHttpRequest -Times 2 -Exactly -ParameterFilter { $Request.Uri -match '/subscriptions$' } + & $script:M { @($script:InforcerTenantListCache.Tenants | Where-Object { $_.PSObject.Properties['subscriptions'] }).Count } | Should -Be 0 + } + + It 'beta: stops with RequiresApiClient and makes no request' { + Set-V1TenantsSession -Beta + Get-InforcerTenant -IncludeSubscriptions -ErrorAction SilentlyContinue -ErrorVariable e + $e[-1].FullyQualifiedErrorId | Should -BeLike 'RequiresApiClient*' + Should -Invoke -ModuleName InforcerCommunity Invoke-InforcerHttpRequest -Times 0 -Exactly + } +} + Describe 'Resolve-InforcerBaselineId' { It 'v1: resolves a baseline name case-insensitively through the neutral /baselines endpoint' { Set-V1TenantsSession diff --git a/Tests/V1.UserWrite.Tests.ps1 b/Tests/V1.UserWrite.Tests.ps1 new file mode 100644 index 0000000..f974ba1 --- /dev/null +++ b/Tests/V1.UserWrite.Tests.ps1 @@ -0,0 +1,690 @@ +# V1.UserWrite.Tests.ps1 +# New-InforcerUser, Set-InforcerUser and Get-InforcerUser -IncludeAuthenticationMethods (v1 only). Fixtures are anonymised; no network calls. + +BeforeAll { + Remove-Module -Name 'InforcerCommunity' -ErrorAction SilentlyContinue + Import-Module (Join-Path $PSScriptRoot '../module/InforcerCommunity.psd1') -Force + + $script:Tid = '00000000-0000-0000-0000-000000000001' + $script:Uid = '00000000-0000-0000-0000-000000000005' + $script:Pw = ConvertTo-SecureString 'Example-Passw0rd!' -AsPlainText -Force + + function global:New-UwResponse { + param([string]$Json, [int]$Status = 200) + $body = if ($Json) { $Json | ConvertFrom-Json -Depth 100 } else { '' } + [pscustomobject]@{ StatusCode = $Status; Body = $body; Headers = @{} } + } + + function global:Set-UwSession { + param([switch]$Beta) + & (Get-Module InforcerCommunity) { + param($Beta) + $script:InforcerTenantListCache = $null + $script:InforcerSession = @{ + AuthMode = $(if ($Beta) { 'ApiKey' } else { 'ClientCredentials' }); ApiVersion = $(if ($Beta) { 'beta' } else { 'v1' }) + ApiHost = 'https://api.example.invalid'; BaseUrl = 'https://api.example.invalid'; Region = 'uk'; ConnectedAt = Get-Date + ApiKey = (ConvertTo-SecureString 'beta-test-key-value' -AsPlainText -Force) + ClientId = 'client-id-example' + ClientSecret = (ConvertTo-SecureString 'client-secret-example-value' -AsPlainText -Force) + AccessToken = (ConvertTo-SecureString 'access-token-example-value' -AsPlainText -Force) + TokenExpiresAt = [datetime]::UtcNow.AddMinutes(50) + } + } $Beta.IsPresent + } + + function global:Set-UwRoute { + param([scriptblock]$Route) + $global:UwCalls = [System.Collections.Generic.List[object]]::new() + $global:UwRoute = $Route + Mock -ModuleName InforcerCommunity Invoke-InforcerHttpRequest { + $global:UwCalls.Add([pscustomobject]@{ Uri = [string]$Request.Uri; Method = $Request.Method; Body = $Request.Body }) + & $global:UwRoute ([string]$Request.Uri) $Request.Method $Request.Body + } + } +} + +AfterAll { + foreach ($f in 'New-UwResponse', 'Set-UwSession', 'Set-UwRoute') { Remove-Item "function:global:$f" -ErrorAction SilentlyContinue } + Remove-Variable -Name UwCalls, UwRoute, UwPolls, UwClock -Scope Global -ErrorAction SilentlyContinue + & (Get-Module InforcerCommunity) { $script:InforcerSession = $null; $script:InforcerTenantListCache = $null } +} + +Describe 'New-InforcerUser' { + It 'POSTs the required fields, defaults and the password, and returns the new id' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse ('{"id":"' + $script:Uid + '"}') 201 } + $u = New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $script:Pw -Department 'Sales' + $global:UwCalls.Count | Should -Be 1 + $global:UwCalls[0].Method | Should -Be 'POST' + $global:UwCalls[0].Uri | Should -Be "https://api.example.invalid/v1/tenants/$($script:Tid)/users" + $b = $global:UwCalls[0].Body | ConvertFrom-Json + $b.displayName | Should -Be 'Jo Bloggs' + $b.userPrincipalName | Should -Be 'jo.bloggs@contoso.com' + $b.mailNickname | Should -Be 'jo.bloggs' + $b.accountEnabled | Should -BeTrue + $b.department | Should -Be 'Sales' + $b.passwordProfile.password | Should -Be 'Example-Passw0rd!' + $b.passwordProfile.forceChangePasswordNextSignIn | Should -BeTrue + $b.PSObject.Properties.Name | Should -Not -Contain 'outputType' + $b.PSObject.Properties.Name | Should -Not -Contain 'tenantId' + $u.id | Should -Be $script:Uid + $u.TenantId | Should -Be $script:Tid + $u.userPrincipalName | Should -Be 'jo.bloggs@contoso.com' + $u.PSObject.TypeNames[0] | Should -Be 'InforcerCommunity.CreatedUser' + } + + It 'sends -AccountEnabled $false, -MailNickname and -ForceChangePasswordNextSignIn $false as given' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"x"}' 201 } + $null = New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -AccountEnabled $false -MailNickname 'jb' -ForceChangePasswordNextSignIn $false -BusinessPhones '+44 20 0000 0000' + $b = $global:UwCalls[0].Body | ConvertFrom-Json + $b.accountEnabled | Should -BeFalse + $b.mailNickname | Should -Be 'jb' + $b.passwordProfile.forceChangePasswordNextSignIn | Should -BeFalse + @($b.businessPhones).Count | Should -Be 1 + $global:UwCalls[0].Body.Contains('"businessPhones":["+44 20 0000 0000"]') | Should -BeTrue + } + + It 'keeps the password out of verbose output' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"x"}' 201 } + $verbose = New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -Verbose 4>&1 | Where-Object { $_ -is [System.Management.Automation.VerboseRecord] } + ($verbose | Out-String) | Should -Not -BeLike '*Example-Passw0rd!*' + } + + It 'leaves no readable password in the retained request after a transport failure' { + Set-UwSession + $global:UwSent = $null + Mock -ModuleName InforcerCommunity Invoke-InforcerHttpRequest { + # What a failed Invoke-RestMethod leaves: the disposed request as the ErrorRecord's TargetObject. + $msg = [System.Net.Http.HttpRequestMessage]::new('POST', [string]$Request.Uri) + $msg.Content = [System.Net.Http.StringContent]::new($Request.Body) + $msg.Dispose() + $global:UwSent = $msg + throw [System.Management.Automation.ErrorRecord]::new([System.Net.Http.HttpRequestException]::new('No such host is known.'), 'WebCmdletWebResponseException', 'ConnectionError', $msg) + } + New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -ErrorAction SilentlyContinue -ErrorVariable e + ($e | Out-String) | Should -Not -BeLike '*Example-Passw0rd!*' + $field = [System.Net.Http.ByteArrayContent].GetField('_content', [System.Reflection.BindingFlags]'NonPublic, Instance') + $field | Should -Not -BeNullOrEmpty -Because 'the cleanup relies on this field; a runtime without it needs another approach' + [System.Text.Encoding]::UTF8.GetString($field.GetValue($global:UwSent.Content)) | Should -Not -BeLike '*Example-Passw0rd!*' + Remove-Variable -Name UwSent -Scope Global + } + + It 'makes no request with -WhatIf' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"x"}' 201 } + New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -WhatIf + $global:UwCalls.Count | Should -Be 0 + } + + It 'refuses an API-key (beta) login with RequiresApiClient and makes no request' { + Set-UwSession -Beta + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"x"}' 201 } + New-InforcerUser -TenantId 5 -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -ErrorAction SilentlyContinue -ErrorVariable e + $e[0].FullyQualifiedErrorId | Should -BeLike 'RequiresApiClient*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'surfaces a 409 conflict with the API reason' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"title":"Conflict","status":409,"detail":"A user with this userPrincipalName already exists"}' 409 } + { New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -ErrorAction Stop } | Should -Throw '*HTTP 409*already exists*' + } + + It 'returns one JSON array for piped tenants with -OutputType JsonObject' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"x"}' 201 } + $json = @([pscustomobject]@{ MsTenantId = $script:Tid }, [pscustomobject]@{ MsTenantId = '00000000-0000-0000-0000-000000000002' }) | + New-InforcerUser -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -OutputType JsonObject + @($json).Count | Should -Be 1 + @($json | ConvertFrom-Json).Count | Should -Be 2 + } +} + +Describe 'Set-InforcerUser' { + It 'PATCHes only the passed fields, and a 204 returns nothing without an error' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + $out = Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Department 'Sales' -AccountEnabled $false -ErrorVariable e + $out | Should -BeNullOrEmpty + $e | Should -BeNullOrEmpty + $global:UwCalls[0].Method | Should -Be 'PATCH' + $global:UwCalls[0].Uri | Should -Be "https://api.example.invalid/v1/tenants/$($script:Tid)/users/$($script:Uid)" + $b = $global:UwCalls[0].Body | ConvertFrom-Json + @($b.PSObject.Properties.Name) | Sort-Object | Should -Be @('accountEnabled', 'department') + $b.accountEnabled | Should -BeFalse + } + + It "sends null for '' and empty arrays, so the fields are cleared" { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -JobTitle '' -ManagerId $null -OtherMails @() + $global:UwCalls[0].Body | Should -Be '{"jobTitle":null,"otherMails":null,"managerId":null}' + } + + It 'refuses to clear a field the API cannot clear' { + { Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -DisplayName '' } | Should -Throw + } + + It 'refuses a call without any change and makes no request' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ErrorAction SilentlyContinue -ErrorVariable e + $e[0].FullyQualifiedErrorId | Should -BeLike 'NoChangeSpecified*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'takes users from the pipeline by id' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + @([pscustomobject]@{ id = 'u1' }, [pscustomobject]@{ id = 'u2' }) | Set-InforcerUser -TenantId $script:Tid -Department 'Sales' + $global:UwCalls.Count | Should -Be 2 + $global:UwCalls[1].Uri | Should -BeLike '*/users/u2' + } + + It 'refuses an API-key (beta) login with RequiresApiClient' { + Set-UwSession -Beta + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId 5 -UserId $script:Uid -Department 'Sales' -ErrorAction SilentlyContinue -ErrorVariable e + $e[0].FullyQualifiedErrorId | Should -BeLike 'RequiresApiClient*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'lists each step when the update was only partly applied (502)' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + New-UwResponse '{"title":"Bad gateway","status":502,"detail":"The manager could not be changed","results":[{"step":"profile","status":"succeeded"},{"step":"manager","status":"failed","title":"Manager not found","statusCode":404}]}' 502 + } + { Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Department 'Sales' -ManagerId $script:Tid -ErrorAction Stop } | + Should -Throw '*HTTP 502*Steps: profile: succeeded; manager: failed (Manager not found)*' + } + It 'resets the password and signs the user out, after the profile update, in that order' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + $out = Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AccountEnabled $false -Password $script:Pw -RevokeSessions -ErrorVariable e + $out | Should -BeNullOrEmpty + $e | Should -BeNullOrEmpty + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('PATCH ', 'POST /password', 'POST /revokeSessions') + $global:UwCalls[1].Body | Should -Be '{"password":"Example-Passw0rd!","forceChangePasswordNextSignIn":true}' + $global:UwCalls[2].Body | Should -BeNullOrEmpty + } + + It 'sends -ForceChangePasswordNextSignIn $false and no PATCH when only the password changes' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Password $script:Pw -ForceChangePasswordNextSignIn $false + $global:UwCalls.Count | Should -Be 1 + $global:UwCalls[0].Uri | Should -Be "https://api.example.invalid/v1/tenants/$($script:Tid)/users/$($script:Uid)/password" + ($global:UwCalls[0].Body | ConvertFrom-Json).forceChangePasswordNextSignIn | Should -BeFalse + } + + It 'refuses -ForceChangePasswordNextSignIn without -Password and makes no request' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ForceChangePasswordNextSignIn $false -ErrorAction SilentlyContinue -ErrorVariable e + $e[0].FullyQualifiedErrorId | Should -BeLike 'PasswordRequired*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'keeps the new password out of verbose output and errors' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"title":"The request is invalid","status":400,"errors":{"password":["The password does not meet the tenant policy"]}}' 400 } + $all = Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Password $script:Pw -Verbose -ErrorAction SilentlyContinue -ErrorVariable e 4>&1 + ($all | Out-String) + ($e | Out-String) | Should -Not -BeLike '*Example-Passw0rd!*' + @($e).Count | Should -Be 1 + $e[0].Exception.Message | Should -BeLike '*HTTP 400*' + } + + It 'stops at the failing step and says what was already done and what was skipped' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/password') { return New-UwResponse '{"title":"The request is invalid","status":400,"errors":{"password":["The password does not meet the tenant policy"]}}' 400 } + New-UwResponse '' 204 + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Department 'Sales' -Password $script:Pw -RevokeSessions -ErrorAction SilentlyContinue -ErrorVariable e + $global:UwCalls.Count | Should -Be 2 + $e[-1].FullyQualifiedErrorId | Should -BeLike 'UserUpdatePartlyApplied*' + $e[-1].Exception.Message | Should -BeLike '*Could not reset password*HTTP 400*Already done: update department.*Not done: sign out of every session.*' + } + + It 'makes no request with -WhatIf for a password reset or sign-out' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Password $script:Pw -RevokeSessions -WhatIf + $global:UwCalls.Count | Should -Be 0 + } + + It 'removes sign-in methods after the password reset and before the sign-out, one DELETE per id' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Password $script:Pw -RemoveAuthenticationMethod 'm1', 'pass/key+1', 'm1' -RevokeSessions -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('POST /password', 'DELETE /authenticationMethods/m1', 'DELETE /authenticationMethods/pass%2Fkey%2B1', 'POST /revokeSessions') + } + + It 'stops at a refused sign-in method and names the methods not removed' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/m1') { return New-UwResponse '{"title":"The request is invalid","status":400,"detail":"The default method cannot be deleted while another phone remains"}' 400 } + New-UwResponse '' 204 + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -RemoveAuthenticationMethod 'm1', 'm2' -RevokeSessions -ErrorAction SilentlyContinue -ErrorVariable e + $global:UwCalls.Count | Should -Be 1 + $e[-1].Exception.Message | Should -BeLike '*Could not remove authentication method m1*HTTP 400*default method*Not done: remove authentication method m2; sign out of every session.*' + } + + It 'resets MFA with one DELETE after the password reset and before the sign-out' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -Password $script:Pw -ResetMfa -RevokeSessions -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('POST /password', 'DELETE /mfa', 'POST /revokeSessions') + } + + It 'names each method and its outcome when Microsoft Entra refuses one during an MFA reset' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"title":"Not every method was deleted","status":400,"results":[{"step":"phone","id":"m1","status":"succeeded"},{"step":"fido2","id":"pk/1","status":"failed","title":"Method is in use"}]}' 400 } + { Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ResetMfa -ErrorAction Stop } | + Should -Throw '*HTTP 400*Steps: phone m1: succeeded; fido2 pk/1: failed (Method is in use)*' + } + + It 'changes licences after the profile and before the password, in one request' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + $b1 = '00000000-0000-0000-0000-0000000000b1'; $b2 = '00000000-0000-0000-0000-0000000000b2' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -UsageLocation 'GB' -AddLicense $b1, $b1 -RemoveLicense $b2 -Password $script:Pw -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('PATCH ', 'POST /assignLicenses', 'POST /password') + $global:UwCalls[1].Body | Should -Be ('{"addSkuIds":["' + $b1 + '"],"removeSkuIds":["' + $b2 + '"]}') + } + + It 'returns the Temporary Access Pass after the MFA reset, even when the sign-out then fails' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/temporaryAccessPasses') { return New-UwResponse '{"id":"tap-1","temporaryAccessPass":"Example-Tap1","startDateTime":"2026-11-15T10:00:00+00:00","lifetimeInMinutes":60,"usableOnce":true}' 201 } + if ($Uri -like '*/revokeSessions') { return New-UwResponse '{"title":"Bad gateway","status":502}' 502 } + New-UwResponse '' 204 + } + $out = Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ResetMfa -TemporaryAccessPass -TemporaryAccessPassLifetime 60 -TemporaryAccessPassUsableOnce $true -RevokeSessions -ErrorAction SilentlyContinue -ErrorVariable e + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('DELETE /mfa', 'POST /authenticationMethods/temporaryAccessPasses', 'POST /revokeSessions') + $global:UwCalls[1].Body | Should -Be '{"lifetimeInMinutes":60,"usableOnce":true}' + $out.temporaryAccessPass | Should -Be 'Example-Tap1' + $out.userId | Should -Be $script:Uid + $e[-1].Exception.Message | Should -BeLike '*Could not sign out of every session*Already done: reset MFA; create Temporary Access Pass.*' + } + + It 'sends an empty body for a Temporary Access Pass without options' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"tap-1","temporaryAccessPass":"Example-Tap1"}' 201 } + $out = Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -TemporaryAccessPass + $global:UwCalls[0].Body | Should -Be '{}' + $out.id | Should -Be 'tap-1' + } + + It 'refuses Temporary Access Pass options without -TemporaryAccessPass, without a request' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -RevokeSessions -TemporaryAccessPassLifetime 60 -ErrorAction SilentlyContinue -ErrorVariable e + $e[-1].FullyQualifiedErrorId | Should -BeLike 'TemporaryAccessPassRequired*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'hides the mailbox before removing licences and waits until Exchange Online reports it done' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + $global:UwPolls = 0 + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/addressListVisibility') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + if ($Uri -like '*/mailbox/actions/*') { + $global:UwPolls++ + $status = if ($global:UwPolls -lt 2) { 'running' } else { 'succeeded' } + return New-UwResponse ('{"actionId":"00000000-0000-0000-0000-0000000000a1","action":"setAddressListVisibility","status":"' + $status + '","queuedBehind":null,"requestedAt":"2026-11-16T10:00:00Z","completedAt":null,"error":null}') + } + New-UwResponse '' 204 + } + $b1 = '00000000-0000-0000-0000-0000000000b1' + $out = Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -RemoveLicense $b1 -HiddenFromAddressLists $true -RevokeSessions -ErrorVariable e -WarningVariable w + $e | Should -BeNullOrEmpty + $w | Should -BeNullOrEmpty + $out | Should -BeNullOrEmpty + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('PATCH /mailbox/addressListVisibility', 'GET /mailbox/actions/00000000-0000-0000-0000-0000000000a1', 'GET /mailbox/actions/00000000-0000-0000-0000-0000000000a1', 'POST /assignLicenses', 'POST /revokeSessions') + $global:UwCalls[0].Body | Should -Be '{"hidden":true}' + } + + It 'sends hidden false to show the mailbox again' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Method -eq 'PATCH') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1","status":"succeeded","error":null}' + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -HiddenFromAddressLists $false -ErrorVariable e + $e | Should -BeNullOrEmpty + $global:UwCalls[0].Body | Should -Be '{"hidden":false}' + } + + It 'stops the later steps when Exchange Online fails the address list change, with its reason' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Method -eq 'PATCH' -and $Uri -like '*/addressListVisibility') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1","status":"failed","error":{"code":"WriteNotApplied","message":"The mailbox was not found"}}' } + New-UwResponse '' 204 + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AccountEnabled $false -HiddenFromAddressLists $true -RevokeSessions -ErrorAction SilentlyContinue -ErrorVariable e + $e[-1].FullyQualifiedErrorId | Should -BeLike 'UserUpdatePartlyApplied*' + $e[-1].Exception.Message | Should -BeLike '*Could not hide mailbox from address lists*The mailbox was not found (WriteNotApplied)*Already done: update accountEnabled.*Not done: sign out of every session.*' + @($global:UwCalls | Where-Object Uri -like '*/revokeSessions').Count | Should -Be 0 + } + + It 'gives the failure itself when the address list change is the only step' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Method -eq 'PATCH') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1","status":"failed","error":{"code":"NotStarted","message":"Exchange Online could not be reached"}}' + } + { Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -HiddenFromAddressLists $true -ErrorAction Stop } | + Should -Throw '*Exchange Online could not be reached (NotStarted)*' + } + + It 'warns and carries on when the change is still queued at the deadline' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + $global:UwClock = [datetime]'2026-11-16T10:00:00' + Mock -ModuleName InforcerCommunity Get-Date { $global:UwClock; $global:UwClock = $global:UwClock.AddMinutes(10) } + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Method -eq 'PATCH') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + New-UwResponse '' 204 + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -HiddenFromAddressLists $true -RevokeSessions -ErrorVariable e -WarningVariable w -WarningAction SilentlyContinue + $e | Should -BeNullOrEmpty + "$w" | Should -BeLike '*still queued*action id 00000000-0000-0000-0000-0000000000a1*' + @($global:UwCalls | ForEach-Object { $_.Method }) | Should -Be @('PATCH', 'POST') + } + + It 'offboards in order: profile, mailbox changes one at a time, then the licence removal and the sign-out' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1","status":"succeeded","error":null}' } + if ($Uri -like '*/mailbox/*') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + New-UwResponse '' 204 + } + $reply = [ordered]@{ status = 'alwaysEnabled'; externalAudience = 'none'; internalReplyMessage = 'Jo has left.' } + $manager = '00000000-0000-0000-0000-000000000006' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AccountEnabled $false -MailboxType Shared -EnableArchive -AutoReply $reply -GrantMailboxPermission @{ permission = 'fullAccess'; trusteeId = $manager; automapping = $true } -RemoveLicense '00000000-0000-0000-0000-0000000000b1' -RevokeSessions -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | Where-Object Uri -notlike '*/mailbox/actions/*' | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('PATCH ', 'PATCH /mailbox/type', 'PATCH /mailbox/archive', 'PATCH /mailbox/autoReply', 'POST /mailbox/permissions', 'POST /assignLicenses', 'POST /revokeSessions') + @($global:UwCalls | Where-Object Uri -like '*/mailbox/actions/*').Count | Should -Be 4 + @($global:UwCalls | Where-Object Uri -like '*/mailbox/archive')[0].Body | Should -Be '{"enabled":true}' + $writes = @($global:UwCalls | Where-Object Uri -match '/mailbox/(type|autoReply|permissions)$') + $writes[0].Body | Should -Be '{"type":"shared"}' + $writes[1].Body | Should -Be '{"status":"alwaysEnabled","externalAudience":"none","internalReplyMessage":"Jo has left."}' + $writes[2].Body | Should -Be ('{"trusteeId":"' + $manager + '","permission":"fullAccess","automapping":true}') + } + + It 'keeps -AddLicense before the mailbox changes, so a new mailbox gets its licence first' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"status":"succeeded","error":null}' } + if ($Uri -like '*/mailbox/*') { return New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 } + New-UwResponse '' 204 + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AddLicense '00000000-0000-0000-0000-0000000000b1' -HiddenFromAddressLists $true -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | Where-Object Uri -notlike '*/mailbox/actions/*' | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('POST /assignLicenses', 'PATCH /mailbox/addressListVisibility') + } + + It 'sends a read automatic reply back without nulls and simplified, and only status when it is disabled' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"status":"succeeded","error":null}' } + New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 + } + $read = '{"status":"scheduled","externalAudience":"all","internalReplyMessage":"Away","externalReplyMessage":"Away","scheduledStartDateTime":"2026-12-01T09:00:00+01:00","scheduledEndDateTime":null,"simplified":true}' | ConvertFrom-Json + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AutoReply $read -ErrorVariable e + $e | Should -BeNullOrEmpty + $global:UwCalls[0].Body | Should -Be '{"status":"scheduled","externalAudience":"all","internalReplyMessage":"Away","externalReplyMessage":"Away","scheduledStartDateTime":"2026-12-01T08:00:00Z"}' + $read.status = 'disabled' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AutoReply $read + @($global:UwCalls | Where-Object Method -eq 'PATCH')[-1].Body | Should -Be '{"status":"disabled"}' + } + + It 'forwards to a user id or to an address, and refuses conflicting forwarding options without a request' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"status":"succeeded","error":null}' } + New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 + } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ForwardTo '00000000-0000-0000-0000-000000000006' -KeepForwardedCopy + $global:UwCalls[0].Body | Should -Be '{"recipientUserId":"00000000-0000-0000-0000-000000000006","keepCopy":true}' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ForwardTo 'sales@contoso.com' + @($global:UwCalls | Where-Object Method -eq 'PATCH')[-1].Body | Should -Be '{"smtpAddress":"sales@contoso.com","keepCopy":false}' + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -ForwardTo 'sales@contoso.com' -RemoveForwarding -ErrorAction SilentlyContinue -ErrorVariable e1 + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -KeepForwardedCopy -RevokeSessions -ErrorAction SilentlyContinue -ErrorVariable e2 + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -GrantMailboxPermission @{ permission = 'sendAs' } -ErrorAction SilentlyContinue -ErrorVariable e3 + $e1[-1].FullyQualifiedErrorId | Should -BeLike 'ConflictingForwarding*' + $e2[-1].FullyQualifiedErrorId | Should -BeLike 'ForwardToRequired*' + $e3[-1].FullyQualifiedErrorId | Should -BeLike 'InvalidMailboxPermission*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'adds addresses before making one primary and removing the old one, and builds the remove paths' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"status":"succeeded","error":null}' } + New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 + } + $g = '00000000-0000-0000-0000-0000000000c1' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -RemoveEmailAddress 'jo@contoso.com' -PrimaryEmailAddress 'jo.bloggs@contoso.com' -AddEmailAddress 'jb@contoso.com' -RemoveForwarding -RemoveMailboxPermission ([pscustomobject]@{ permission = 'sendAs'; trusteeId = '00000000-0000-0000-0000-000000000006'; displayName = 'Sam' }) -AddMailGroup $g -RemoveMailGroup $g -RemoveInboxRule '1234' -RemoveAllInboxRules -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | Where-Object Uri -notlike '*/mailbox/actions/*' | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+/mailbox', '')" }) | + Should -Be @('POST /emailAddresses', 'POST /emailAddresses', 'DELETE /emailAddresses/jo%40contoso.com', 'DELETE /forwarding', + 'DELETE /permissions/sendAs/00000000-0000-0000-0000-000000000006', "POST /mailGroups", "DELETE /mailGroups/$g", 'DELETE /inboxRules/1234', 'DELETE /inboxRules?all=true') + $global:UwCalls[0].Body | Should -Be '{"address":"jb@contoso.com"}' + $global:UwCalls[2].Body | Should -Be '{"address":"jo.bloggs@contoso.com","primary":true}' + @($global:UwCalls | Where-Object { $_.Uri -like '*/mailGroups' })[0].Body | Should -Be ('{"groupId":"' + $g + '"}') + } + + It 'shares and unshares the calendar and sets mail apps in one change with the API spelling, after the inbox rules' { + Set-UwSession + Mock -ModuleName InforcerCommunity Start-Sleep {} + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox/actions/*') { return New-UwResponse '{"status":"succeeded","error":null}' } + New-UwResponse '{"actionId":"00000000-0000-0000-0000-0000000000a1"}' 202 + } + $t = '00000000-0000-0000-0000-000000000006' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -BlockMailApp imap, POP -AllowMailApp outlookweb -RemoveAllInboxRules -RemoveCalendarAccess $t -GrantCalendarAccess @{ trusteeId = $t; role = 'Editor' } -ErrorVariable e + $e | Should -BeNullOrEmpty + $writes = @($global:UwCalls | Where-Object Uri -notlike '*/mailbox/actions/*') + @($writes | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+/mailbox', '')" }) | + Should -Be @('POST /calendarAccess', "DELETE /calendarAccess/$t", 'DELETE /inboxRules?all=true', 'PATCH /mailApps') + $writes[0].Body | Should -Be ('{"trusteeId":"' + $t + '","role":"editor"}') + $writes[3].Body | Should -Be '{"outlookWeb":true,"imap":false,"pop":false}' + } + + It 'refuses a calendar share without a valid role and an app both allowed and blocked, without a request' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -GrantCalendarAccess @{ trusteeId = '00000000-0000-0000-0000-000000000006'; role = 'owner' } -ErrorAction SilentlyContinue -ErrorVariable e1 + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AllowMailApp Pop -BlockMailApp pop -ErrorAction SilentlyContinue -ErrorVariable e2 + $e1[-1].FullyQualifiedErrorId | Should -BeLike 'InvalidCalendarAccess*' + $e2[-1].FullyQualifiedErrorId | Should -BeLike 'ConflictingMailApp*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'sends userType on create and update' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse ('{"id":"' + $script:Uid + '"}') 201 } + $null = New-InforcerUser -TenantId $script:Tid -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $script:Pw -UserType Guest + $global:UwCalls[0].Body | Should -Match '"userType":"Guest"' + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -UserType Member + $global:UwCalls[0].Body | Should -Be '{"userType":"Member"}' + } + + It 'adds to groups after the licences and removes only once the add succeeded' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + $g1 = '00000000-0000-0000-0000-0000000000c1'; $g2 = '00000000-0000-0000-0000-0000000000c2' + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AddLicense '00000000-0000-0000-0000-0000000000b1' -AddGroup $g2, $g2 -RemoveGroup $g1 -ErrorVariable e + $e | Should -BeNullOrEmpty + @($global:UwCalls | ForEach-Object { "$($_.Method) $($_.Uri -replace '^.*/users/[^/]+', '')" }) | + Should -Be @('POST /assignLicenses', 'POST /groups', 'POST /groups') + $global:UwCalls[1].Body | Should -Be ('{"add":["' + $g2 + '"]}') + $global:UwCalls[2].Body | Should -Be ('{"remove":["' + $g1 + '"]}') + + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"title":"Group is role-assignable","status":400}' 400 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AddGroup $g2 -RemoveGroup $g1 -ErrorAction SilentlyContinue -ErrorVariable e2 + $global:UwCalls.Count | Should -Be 1 + $e2[-1].Exception.Message | Should -BeLike '*Could not add to groups*Not done: remove from groups*' + + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '' 204 } + Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -AddGroup $g1 -RemoveGroup $g1 -ErrorAction SilentlyContinue -ErrorVariable e3 + $e3[-1].FullyQualifiedErrorId | Should -BeLike 'ConflictingGroup*' + $global:UwCalls.Count | Should -Be 0 + } + + It 'surfaces a 404 from a sign-out alone with the original error' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"title":"User not found","status":404}' 404 } + { Set-InforcerUser -TenantId $script:Tid -UserId $script:Uid -RevokeSessions -ErrorAction Stop } | Should -Throw '*HTTP 404*User not found*' + } +} + +Describe 'Get-InforcerUser -IncludeAuthenticationMethods' { + It 'adds the authentication methods to the user with one extra request' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/authenticationMethods') { + return New-UwResponse '{"authenticationMethods":[{"id":"00000000-0000-0000-0000-0000000000a1","type":"password","displayName":null,"createdDateTime":null,"deletable":false,"phoneNumber":null,"phoneType":null,"emailAddress":null},{"id":"00000000-0000-0000-0000-0000000000a2","type":"phone","displayName":null,"createdDateTime":null,"deletable":true,"phoneNumber":"+44 7700 900000","phoneType":"mobile","emailAddress":null}]}' + } + New-UwResponse ('{"id":"' + $script:Uid + '","displayName":"Jo Bloggs"}') + } + $u = Get-InforcerUser -TenantId $script:Tid -UserId $script:Uid -IncludeAuthenticationMethods + $global:UwCalls.Count | Should -Be 2 + $global:UwCalls[1].Uri | Should -Be "https://api.example.invalid/v1/tenants/$($script:Tid)/users/$($script:Uid)/authenticationMethods" + @($u.authenticationMethods).Count | Should -Be 2 + $u.authenticationMethods[1].phoneType | Should -Be 'mobile' + } + + It 'keeps a single method as an array in JSON output' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/authenticationMethods') { return New-UwResponse '{"authenticationMethods":[{"id":"m1","type":"password"}]}' } + New-UwResponse '{"id":"u1"}' + } + $json = Get-InforcerUser -TenantId $script:Tid -UserId 'u1' -IncludeAuthenticationMethods -OutputType JsonObject + $json | Should -Match '"authenticationMethods":\s*\[' + } + + It 'makes no extra request without the switch' { + Set-UwSession + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"id":"u1"}' } + $null = Get-InforcerUser -TenantId $script:Tid -UserId 'u1' + $global:UwCalls.Count | Should -Be 1 + } + + It 'refuses an API-key (beta) login with RequiresApiClient and makes no request' { + Set-UwSession -Beta + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"data":{"id":"u1"},"success":true}' } + Get-InforcerUser -TenantId 5 -UserId 'u1' -IncludeAuthenticationMethods -ErrorAction SilentlyContinue -ErrorVariable e + $e[0].FullyQualifiedErrorId | Should -BeLike 'RequiresApiClient*' + $global:UwCalls.Count | Should -Be 0 + } +} + +Describe 'Get-InforcerUser -IncludeMailbox' { + It 'adds the mailbox with its automatic replies, permissions, calendar access, mail groups and inbox rules' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + switch -Wildcard ($Uri) { + '*/mailbox' { return New-UwResponse '{"displayName":"Jo Bloggs","type":"user","emailAddresses":[{"address":"jo@contoso.com","primary":true}],"onPremisesSyncEnabled":false,"hiddenFromAddressList":false,"litigationHold":false,"size":null,"archive":null,"forwarding":{"enabled":false,"recipientUserId":null,"recipientDisplayName":null,"smtpAddress":null,"keepCopy":false}}' } + '*/mailbox/autoReply' { return New-UwResponse '{"status":"disabled","externalAudience":"none","internalReplyMessage":"","externalReplyMessage":"","scheduledStartDateTime":null,"scheduledEndDateTime":null,"simplified":false}' } + '*/mailbox/permissions' { return New-UwResponse '{"permissions":[{"permission":"fullAccess","trusteeId":"00000000-0000-0000-0000-000000000006","displayName":"Sam","inherited":false}],"unreadPermissions":["sendOnBehalf"]}' } + '*/mailbox/calendarAccess' { return New-UwResponse '{"calendarAccess":[{"trusteeId":"00000000-0000-0000-0000-000000000006","displayName":"Sam","role":"delegate"}]}' } + '*/mailbox/mailGroups' { return New-UwResponse '{"mailGroups":[]}' } + '*/mailbox/inboxRules' { return New-UwResponse '{"inboxRules":[{"id":"1234","name":"Fwd","enabled":true,"description":null,"deletesMessages":false,"hidden":false,"deletable":true,"forwardsExternally":true,"recipients":[]}]}' } + } + New-UwResponse ('{"id":"' + $script:Uid + '","displayName":"Jo Bloggs"}') + } + $u = Get-InforcerUser -TenantId $script:Tid -UserId $script:Uid -IncludeMailbox -ErrorVariable e + $e | Should -BeNullOrEmpty + $global:UwCalls.Count | Should -Be 7 + $u.mailbox.type | Should -Be 'user' + $u.mailbox.calendarAccess[0].role | Should -Be 'delegate' + $u.mailbox.autoReply.status | Should -Be 'disabled' + $u.mailbox.permissions[0].trusteeId | Should -Be '00000000-0000-0000-0000-000000000006' + @($u.mailbox.unreadPermissions) | Should -Be @('sendOnBehalf') + @($u.mailbox.mailGroups).Count | Should -Be 0 + $u.mailbox.inboxRules[0].forwardsExternally | Should -BeTrue + $json = Get-InforcerUser -TenantId $script:Tid -UserId $script:Uid -IncludeMailbox -OutputType JsonObject + $json | Should -Match '"mailGroups":\s*\[\]' + } + + It 'sets mailbox to null without an error or more requests when the user has no mailbox' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox') { return New-UwResponse '{"title":"Mailbox not found","status":404}' 404 } + New-UwResponse '{"id":"u1"}' + } + $u = Get-InforcerUser -TenantId $script:Tid -UserId 'u1' -IncludeMailbox -ErrorAction Stop + $global:UwCalls.Count | Should -Be 2 + $u.PSObject.Properties['mailbox'] | Should -Not -BeNullOrEmpty + $u.mailbox | Should -BeNullOrEmpty + } + + It 'reports any other failure and leaves mailbox out rather than saying there is none' { + Set-UwSession + Set-UwRoute { + param($Uri, $Method, $Body) + if ($Uri -like '*/mailbox') { return New-UwResponse '{"title":"Bad gateway","status":502}' 502 } + New-UwResponse '{"id":"u1"}' + } + $u = Get-InforcerUser -TenantId $script:Tid -UserId 'u1' -IncludeMailbox -ErrorAction SilentlyContinue -ErrorVariable e + "$($e[-1])" | Should -BeLike '*502*' + $u.PSObject.Properties['mailbox'] | Should -BeNullOrEmpty + } + + It 'refuses an API-key (beta) login with RequiresApiClient and makes no request' { + Set-UwSession -Beta + Set-UwRoute { param($Uri, $Method, $Body) New-UwResponse '{"data":{"id":"u1"},"success":true}' } + Get-InforcerUser -TenantId 5 -UserId 'u1' -IncludeMailbox -ErrorAction SilentlyContinue -ErrorVariable e + $e[0].FullyQualifiedErrorId | Should -BeLike 'RequiresApiClient*' + $global:UwCalls.Count | Should -Be 0 + } +} diff --git a/docs/API-REFERENCE.md b/docs/API-REFERENCE.md index e60b05b..9ae5a57 100644 --- a/docs/API-REFERENCE.md +++ b/docs/API-REFERENCE.md @@ -21,6 +21,7 @@ This document describes the inforcer REST API endpoints, schemas, and response s - [Rate limits](#rate-limits) - [failedPolicyTypes](#failedpolicytypes) - [v1 endpoints](#v1-endpoints) + - [Managing users (v1 only)](#managing-users-v1-only) - [How v1 fields map to the module's names](#how-v1-fields-map-to-the-modules-names) - [Alignment details renames](#alignment-details-renames) - [Beta endpoints](#beta-endpoints) @@ -45,6 +46,7 @@ This document describes the inforcer REST API endpoints, schemas, and response s - [TenantTag](#tenanttag) - [AlignmentSummary](#alignmentsummary) - [TenantLicense](#tenantlicense) + - [Subscription](#subscription) - [Policy](#policy) - [PolicyTag](#policytag) - [EventType](#eventtype) @@ -52,6 +54,15 @@ This document describes the inforcer REST API endpoints, schemas, and response s - [UserSummary](#usersummary) - [User](#user) - [UserLicense](#userlicense) + - [CreatedUser](#createduser) + - [UserUpdate](#userupdate) + - [PasswordReset](#passwordreset) + - [UserLicenseAssignment](#userlicenseassignment) + - [UserGroupsChange](#usergroupschange) + - [TemporaryAccessPass](#temporaryaccesspass) + - [MailboxAction](#mailboxaction) + - [Mailbox](#mailbox) + - [UserAuthenticationMethod](#userauthenticationmethod) - [TenantGroupSummary](#tenantgroupsummary) - [TenantGroup](#tenantgroup) - [TenantRole](#tenantrole) @@ -142,7 +153,9 @@ Built mechanically by tracing each public cmdlet through the module (including t | `Get-InforcerAlignmentDetails` | `GET /beta/baselines`, `GET /beta/alignmentScores`, `GET /beta/tenants`, `GET /beta/tenants/{tenantId}/alignmentDetails` | `Baselines.Read` + `AlignmentScores.Read` + `Tenants.Read` + `tenants.policies.Read` | | `Get-InforcerAuditEvent` | `POST /beta/auditEvents/search` (one search; without `-EventType` no event-type filter is sent) | `Audit.Read` *(unmapped — see note above)* | | `Get-InforcerSupportedEventType` | `GET /beta/auditEvents/eventTypes` | `Audit.Read` *(unmapped — see note above)* | -| `Get-InforcerUser` | `GET /beta/tenants/{tenantId}/users[/...] ` + `GET /beta/tenants` *(GUID/name lookup)* | `Tenants.Users.Read` + `Tenants.Read`† | +| `Get-InforcerUser` | `GET /beta/tenants/{tenantId}/users[/...] ` + `GET /beta/tenants` *(GUID/name lookup)*; `-IncludeAuthenticationMethods` has no beta equivalent (needs an API client) | `Tenants.Users.Read` + `Tenants.Read`† | +| `New-InforcerUser` | none: the beta API cannot create users (the cmdlet needs an API client) | not available with an API key | +| `Set-InforcerUser` | none: the beta API cannot update users, reset passwords or revoke sessions (the cmdlet needs an API client) | not available with an API key | | `Get-InforcerGroup` | `GET /beta/tenants/{tenantId}/groups[/...] ` + `GET /beta/tenants` *(GUID/name lookup)* | `Tenants.Groups.Read` + `Tenants.Read`† | | `Get-InforcerRole` | `GET /beta/tenants/{tenantId}/roles` + `GET /beta/tenants` *(GUID/name lookup)* | `Tenants.Roles.Read` + `Tenants.Read`† | | `Get-InforcerSecureScore` | `GET /beta/tenants/{tenantId}/secureScores` + `GET /beta/tenants` *(GUID/name lookup)* | `Tenants.SecureScores.Read` + `Tenants.Read`† | @@ -171,9 +184,10 @@ The permission names below are the ones the portal shows (feature and grant). ** | Area / feature | Grant | v1 routes | Status | |----------------|-------|-----------|--------| -| Tenants / Tenants | Read: View | `/v1/tenants`, `/v1/tenants/{msTenantId}` | unconfirmed | +| Tenants / Tenants | Read: View | `/v1/tenants`, `/v1/tenants/{msTenantId}`, `/v1/tenants/{msTenantId}/subscriptions` | unconfirmed | | Tenants / Policies | Read: View | `/v1/tenants/{msTenantId}/policies` | unconfirmed | -| Tenants / User & Group Management | Read: View | `/v1/tenants/{msTenantId}/users`, `/v1/tenants/{msTenantId}/users/{userId}`, `/v1/tenants/{msTenantId}/groups`, `/v1/tenants/{msTenantId}/groups/{groupId}`, `/v1/tenants/{msTenantId}/groups/{groupId}/members` | unconfirmed | +| Tenants / User & Group Management | Read: View | `/v1/tenants/{msTenantId}/users`, `/v1/tenants/{msTenantId}/users/{userId}`, `/v1/tenants/{msTenantId}/users/{userId}/authenticationMethods`, `/v1/tenants/{msTenantId}/users/{userId}/mailbox` (and its `autoReply`, `permissions`, `calendarAccess`, `mailGroups`, `inboxRules`), `/v1/tenants/{msTenantId}/groups`, `/v1/tenants/{msTenantId}/groups/{groupId}`, `/v1/tenants/{msTenantId}/groups/{groupId}/members` | unconfirmed | +| Tenants / User & Group Management | Write (grant name unconfirmed) | `POST /v1/tenants/{msTenantId}/users`, `PATCH /v1/tenants/{msTenantId}/users/{userId}`, `POST /v1/tenants/{msTenantId}/users/{userId}/password`, `POST /v1/tenants/{msTenantId}/users/{userId}/groups`, `POST /v1/tenants/{msTenantId}/users/{userId}/revokeSessions`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/{methodId}`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mfa`, `POST /v1/tenants/{msTenantId}/users/{userId}/assignLicenses`, `POST /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/temporaryAccessPasses`, `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/addressListVisibility`, `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/type`, `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/archive`, `PATCH`/`DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/forwarding`, `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/autoReply`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses/{address}`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions/{permission}/{trusteeId}`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess/{trusteeId}`, `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailApps`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups/{groupId}`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/inboxRules[/{ruleId}]`, `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox/actions/{actionId}` | unconfirmed (which write grant) | | Tenants / Entra Dashboard | Read: View | `/v1/tenants/{msTenantId}/secureScores`, `/v1/tenants/{msTenantId}/directoryRoles` | unconfirmed | | Align / Baselines | Read: View | `/v1/baselines` | unconfirmed | | Align / Align | Read: View | `/v1/alignmentScores`, `/v1/tenants/{msTenantId}/alignmentDetails` | unconfirmed | @@ -192,13 +206,15 @@ The permission names below are the ones the portal shows (feature and grant). ** | `Connect-Inforcer` | `POST /oauth/token` (no permission needed; any valid client connects) and a best-effort `GET /v1/reports/types` to prime the report catalog | None | | `Disconnect-Inforcer` | none | None | | `Test-InforcerConnection` | `GET /v1/baselines` | Baselines; without it the test returns `False` | -| `Get-InforcerTenant` | `GET /v1/tenants`. `-TenantId ` makes only `GET /v1/tenants/{msTenantId}`; a name adds the cached list | Tenants | +| `Get-InforcerTenant` | `GET /v1/tenants`. `-TenantId ` makes only `GET /v1/tenants/{msTenantId}`; a name adds the cached list. `-IncludeSubscriptions` adds `GET /v1/tenants/{msTenantId}/subscriptions` per tenant | Tenants | | `Get-InforcerBaseline` | `GET /v1/baselines` (+ `GET /v1/tenants` for a tenant name) | Baselines, Tenants† | | `Get-InforcerTenantPolicies` | `GET /v1/tenants/{msTenantId}/policies` | Policies, Tenants† | | `Get-InforcerAlignmentDetails` | `GET /v1/baselines`, `GET /v1/alignmentScores`, `GET /v1/tenants`, `GET /v1/tenants/{msTenantId}/alignmentDetails` | Baselines + Align + Tenants | | `Get-InforcerAuditEvent` | `POST /v1/auditEvents/search` | Activity | | `Get-InforcerSupportedEventType` | `GET /v1/auditEvents/types` | Activity | -| `Get-InforcerUser` | `GET /v1/tenants/{msTenantId}/users[/{userId}]` | User & Group Management, Tenants† | +| `Get-InforcerUser` | `GET /v1/tenants/{msTenantId}/users[/{userId}]`, `.../users/{userId}/authenticationMethods` (with `-IncludeAuthenticationMethods`), `.../users/{userId}/mailbox` and its `autoReply`, `permissions`, `calendarAccess`, `mailGroups`, `inboxRules` (with `-IncludeMailbox`) | User & Group Management, Tenants† | +| `New-InforcerUser` | `POST /v1/tenants/{msTenantId}/users` | User & Group Management (write), Tenants† | +| `Set-InforcerUser` | `PATCH /v1/tenants/{msTenantId}/users/{userId}`, `POST .../users/{userId}/assignLicenses` (with `-AddLicense`/`-RemoveLicense`), `POST .../users/{userId}/groups` (with `-AddGroup`/`-RemoveGroup`), the mailbox writes under `.../users/{userId}/mailbox/` (`type`, `archive`, `addressListVisibility`, `emailAddresses`, `autoReply`, `forwarding`, `permissions`, `calendarAccess`, `mailGroups`, `inboxRules`, `mailApps`; one per mailbox parameter, one for all mail apps), each followed by `GET .../users/{userId}/mailbox/actions/{actionId}` until done, `POST .../users/{userId}/password` (with `-Password`), `DELETE .../users/{userId}/authenticationMethods/{methodId}` (with `-RemoveAuthenticationMethod`), `DELETE .../users/{userId}/mfa` (with `-ResetMfa`), `POST .../users/{userId}/authenticationMethods/temporaryAccessPasses` (with `-TemporaryAccessPass`), `POST .../users/{userId}/revokeSessions` (with `-RevokeSessions`) | User & Group Management (write), Tenants† | | `Get-InforcerGroup` | `GET /v1/tenants/{msTenantId}/groups[/{groupId}]`, `.../groups/{groupId}/members` (with `-Group`) | User & Group Management, Tenants† | | `Get-InforcerRole` | `GET /v1/tenants/{msTenantId}/directoryRoles` | Entra Dashboard, Tenants† | | `Get-InforcerSecureScore` | `GET /v1/tenants/{msTenantId}/secureScores` | Entra Dashboard, Tenants† | @@ -294,11 +310,40 @@ Every path in the v1 spec, its beta equivalent and the module cmdlet. The module |---------|--------|-----------------|--------| | `/v1/tenants` | GET | `/beta/tenants` | `Get-InforcerTenant` | | `/v1/tenants/{msTenantId}` | GET | `/beta/tenants/{tenantId}` | `Get-InforcerTenant -TenantId` (the sanctioned use of this endpoint); also reached through it by Export and Compare | +| `/v1/tenants/{msTenantId}/subscriptions` | GET (`{ "subscriptions": [...] }`, all in one response) | none (v1 only) | `Get-InforcerTenant -IncludeSubscriptions` | | `/v1/tenants/{msTenantId}/policies` | GET | `/beta/tenants/{tenantId}/policies` | `Get-InforcerTenantPolicies`, Export, Compare | | `/v1/tenants/{msTenantId}/alignmentDetails` | GET (`baselineId` required) | `/beta/tenants/{tenantId}/alignmentDetails` (`customBaselineId`) | `Get-InforcerAlignmentDetails`; Export/Compare baseline scoping | | `/v1/tenants/{msTenantId}/secureScores` | GET | `/beta/tenants/{tenantId}/secureScores` | `Get-InforcerSecureScore` | | `/v1/tenants/{msTenantId}/users` | GET (`search`, `continuationToken`) | `/beta/tenants/{tenantId}/users` | `Get-InforcerUser` | +| `/v1/tenants/{msTenantId}/users` | POST (201 `{ id }`) | none (v1 only) | `New-InforcerUser` | | `/v1/tenants/{msTenantId}/users/{userId}` | GET | `/beta/tenants/{tenantId}/users/{userId}` | `Get-InforcerUser -UserId` | +| `/v1/tenants/{msTenantId}/users/{userId}` | PATCH (JSON Merge Patch, 204) | none (v1 only) | `Set-InforcerUser` | +| `/v1/tenants/{msTenantId}/users/{userId}/authenticationMethods` | GET | none (v1 only) | `Get-InforcerUser -UserId -IncludeAuthenticationMethods` | +| `/v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/{methodId}` | DELETE (204) | none (v1 only) | `Set-InforcerUser -RemoveAuthenticationMethod` | +| `/v1/tenants/{msTenantId}/users/{userId}/mfa` | DELETE (204) | none (v1 only) | `Set-InforcerUser -ResetMfa` | +| `/v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/temporaryAccessPasses` | POST (201, pass) | none (v1 only) | `Set-InforcerUser -TemporaryAccessPass` | +| `/v1/tenants/{msTenantId}/users/{userId}/assignLicenses` | POST (204) | none (v1 only) | `Set-InforcerUser -AddLicense`/`-RemoveLicense` | +| `/v1/tenants/{msTenantId}/users/{userId}/groups` | POST (204) | none (v1 only) | `Set-InforcerUser -AddGroup`/`-RemoveGroup` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox` | GET | none (v1 only) | `Get-InforcerUser -UserId -IncludeMailbox` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/type` | PATCH (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -MailboxType` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/archive` | PATCH (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -EnableArchive` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/addressListVisibility` | PATCH (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -HiddenFromAddressLists` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses` | POST (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -AddEmailAddress`/`-PrimaryEmailAddress` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses/{address}` | DELETE (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -RemoveEmailAddress` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/autoReply` | GET, PATCH (202 `{ actionId }`) | none (v1 only) | `Get-InforcerUser -IncludeMailbox`, `Set-InforcerUser -AutoReply` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/forwarding` | PATCH, DELETE (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -ForwardTo`/`-RemoveForwarding` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions` | GET, POST (202 `{ actionId }`) | none (v1 only) | `Get-InforcerUser -IncludeMailbox`, `Set-InforcerUser -GrantMailboxPermission` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions/{permission}/{trusteeId}` | DELETE (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -RemoveMailboxPermission` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess` | GET, POST (202 `{ actionId }`) | none (v1 only) | `Get-InforcerUser -IncludeMailbox`, `Set-InforcerUser -GrantCalendarAccess` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess/{trusteeId}` | DELETE (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -RemoveCalendarAccess` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/mailApps` | PATCH (JSON Merge Patch, 202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -AllowMailApp`/`-BlockMailApp` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups` | GET, POST (202 `{ actionId }`) | none (v1 only) | `Get-InforcerUser -IncludeMailbox`, `Set-InforcerUser -AddMailGroup` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups/{groupId}` | DELETE (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -RemoveMailGroup` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/inboxRules` | GET, DELETE (`all=true`, 202 `{ actionId }`) | none (v1 only) | `Get-InforcerUser -IncludeMailbox`, `Set-InforcerUser -RemoveAllInboxRules` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/inboxRules/{ruleId}` | DELETE (202 `{ actionId }`) | none (v1 only) | `Set-InforcerUser -RemoveInboxRule` | +| `/v1/tenants/{msTenantId}/users/{userId}/mailbox/actions/{actionId}` | GET | none (v1 only) | `Set-InforcerUser` (waits on every mailbox change) | +| `/v1/tenants/{msTenantId}/users/{userId}/password` | POST (204) | none (v1 only) | `Set-InforcerUser -Password` | +| `/v1/tenants/{msTenantId}/users/{userId}/revokeSessions` | POST (204) | none (v1 only) | `Set-InforcerUser -RevokeSessions` | | `/v1/tenants/{msTenantId}/groups` | GET (`search`, `continuationToken`) | `/beta/tenants/{tenantId}/groups` | `Get-InforcerGroup` | | `/v1/tenants/{msTenantId}/groups/{groupId}` | GET | `/beta/tenants/{tenantId}/groups/{groupId}` | `Get-InforcerGroup -Group` | | `/v1/tenants/{msTenantId}/groups/{groupId}/members` | GET (`continuationToken`) | none (v1 only) | `Get-InforcerGroup -Group` (attached as members) | @@ -314,7 +359,230 @@ Every path in the v1 spec, its beta equivalent and the module cmdlet. The module | `/v1/auditEvents/types` | GET (`{ "eventTypes": [ { "name" } ] }`) | `/beta/auditEvents/eventTypes` | `Get-InforcerSupportedEventType` | | `/v1/auditEvents/search` | POST (`user`, `eventTypes`, `dateFrom`, `dateTo` in whole seconds, `pageSize`, `continuationToken`) | `/beta/auditEvents/search` | `Get-InforcerAuditEvent` | -That is 21 paths and 22 operations (`/v1/reports/runs` has GET and POST). Path parameters are `msTenantId` (Microsoft tenant GUID), `userId` (Entra object ID), `groupId`, `assessmentId`, `reportRunId` and `outputId`. Report runs are triggered with `{ "reports": [ { "type", "outputFormat", "collate", "parameters" } ], "msTenantIds": [ ... ] }` (beta: `tenants.includeTenants` with numeric IDs). +That is 48 paths and 57 operations (`/v1/reports/runs` has GET and POST, `/v1/tenants/{msTenantId}/users` GET and POST, `/v1/tenants/{msTenantId}/users/{userId}` GET and PATCH, and the mailbox's `autoReply`, `forwarding`, `permissions`, `calendarAccess`, `mailGroups` and `inboxRules` two methods each). Path parameters are `msTenantId` (Microsoft tenant GUID), `userId` (Entra object ID), `methodId` (an authentication method's `id`; not always a GUID), `actionId` (a mailbox action's id), `permission` (`fullAccess`, `sendAs` or `sendOnBehalf`), `trusteeId` (the Entra object ID of the user holding a mailbox permission or calendar access), `address` (an email address), `ruleId` (an inbox rule's id, digits), `groupId`, `assessmentId`, `reportRunId` and `outputId`. Report runs are triggered with `{ "reports": [ { "type", "outputFormat", "collate", "parameters" } ], "msTenantIds": [ ... ] }` (beta: `tenants.includeTenants` with numeric IDs). + +### Managing users (v1 only) + +The beta API has no equivalent, so `New-InforcerUser`, `Set-InforcerUser` and `Get-InforcerUser -IncludeAuthenticationMethods` need an API client; an API-key login stops with `RequiresApiClient`. + +#### `POST /v1/tenants/{msTenantId}/users` + +Creates a Microsoft Entra user in the tenant. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body: the [UserUpdate](#userupdate) profile fields, of which `accountEnabled`, `displayName`, `mailNickname` and `userPrincipalName` are required, plus `passwordProfile` `{ password, forceChangePasswordNextSignIn }` (both required; the password must meet the tenant's password policy). + +**Response**: `201` with [CreatedUser](#createduser) and a `Location` header. Errors: `400` (invalid field, with `errors{}`), `404` (tenant), `409` (for example the user principal name is taken). + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}` + +Updates a user's profile, manager and whether they can sign in. JSON Merge Patch (RFC 7396): a property left out is kept, `null` clears it. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body: [UserUpdate](#userupdate), at least one property. Sent as `application/json` (the API also takes `application/merge-patch+json`). + +**Response**: `204` without a body; a `GET` (by id or in the list) can show the old values for up to about five minutes; the two are cached separately. When the manager could not be changed but the other changes were saved, the API answers `502` with problem+json and `results[]`: one `{ step, status, title?, statusCode? }` per step (`profile`, `manager`). The module adds them to the error text as `Steps: profile: succeeded; manager: failed (reason)`. + +#### `POST /v1/tenants/{msTenantId}/users/{userId}/password` + +Sets a new password for the user, and can require them to change it when they next sign in. inforcer does not store or log the password. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body: [PasswordReset](#passwordreset), both fields required. + +**Response**: `204` without a body. Errors: `400` (missing field, or the password does not meet the tenant's password policy, in `errors.password`), `404` (tenant or user). + +#### `POST /v1/tenants/{msTenantId}/users/{userId}/revokeSessions` + +Signs the user out of every session by revoking their refresh tokens and session cookies. Access tokens already issued stay valid until they expire, typically within 90 minutes. No body. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +**Response**: `204` without a body. Errors: `404` (tenant or user, `User not found`). + +`Set-InforcerUser` runs the steps of one call in this order: `PATCH` (when a profile field is passed), licences, password, delete authentication methods (one call per id), MFA reset, Temporary Access Pass, revoke sessions. When a step fails the later ones are skipped, and the error (`UserUpdatePartlyApplied`) names the steps already done and the steps not done. + +#### `GET /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods` + +Lists the sign-in methods the user has registered, such as their password, phones, Microsoft Authenticator and passkeys. Secrets such as passwords and Temporary Access Pass codes are never returned. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management *(unconfirmed)* + +**Response**: `200` with `{ "authenticationMethods": [ ... ] }`, all methods in one response in no fixed order (see [UserAuthenticationMethod](#userauthenticationmethod)). `Get-InforcerUser -UserId -IncludeAuthenticationMethods` adds the array to the user as `authenticationMethods`. Like the other `GET` calls, the answer can be up to about five minutes old. + +#### `DELETE /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/{methodId}` + +Deletes one of the user's sign-in methods, such as a phone, Microsoft Authenticator or a passkey, so it can no longer be used to sign in. `methodId` is the method's `id` from the list above; usually a GUID, but not for every type (a passkey's id is not). + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +**Response**: `204` without a body. Errors: `400` when the method is not `deletable` (reason in `errors.methodId`) or Microsoft Entra refuses it, for example the default method while another phone remains (reason in `detail`); `404` (tenant, user or method). Microsoft Entra's reads lag its changes, so the list can still show a deleted method for a short time. `Set-InforcerUser -RemoveAuthenticationMethod` sends one call per id. + +#### `DELETE /v1/tenants/{msTenantId}/users/{userId}/mfa` + +Resets the user's MFA: deletes every authentication method that the list above returns with `deletable` true, in the order Microsoft Entra needs (an alternate mobile phone first, the default method last), so the user must register MFA again. The password is kept. A method already gone counts as deleted, so the call is safe to repeat. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +**Response**: `204` without a body, also when there was nothing to delete. When Microsoft Entra refuses a method the API answers `400` with problem+json and `results[]`: one `{ step, id, status, title? }` per method, `step` being the method's type and `title` the reason; `500` and `502` carry `results[]` too when methods were attempted. The module adds them to the error text as `Steps: phone : succeeded; fido2 : failed (reason)`. `404`: tenant or user. + +#### `POST /v1/tenants/{msTenantId}/users/{userId}/assignLicenses` + +Adds and removes the user's licences in one call. If any licence is refused, nothing changes. Removing a licence the user does not have succeeds. Adding a licence enables all its service plans, including any disabled on a licence the user already has. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body: [UserLicenseAssignment](#userlicenseassignment), at least one licence. + +**Response**: `204` without a body. Errors: `400` (a licence with no free seat, not subscribed to, conflicting with the user's other licences, or given through a group; a refused request that both adds and removes is a `400` on `body`), `404` (tenant or user). + +The `skuId` of a licence comes from the tenant's subscriptions (`GET /v1/tenants/{msTenantId}/subscriptions`, [Subscription](#subscription), which also shows free seats) or from a user's `assignedLicenses` ([UserLicense](#userlicense)). The tenant record lists its licences by part number only (`sku`). + +#### `POST /v1/tenants/{msTenantId}/users/{userId}/groups` + +Adds the user to Microsoft Entra groups and removes them from others in one call. Each group is changed on its own, so a group that cannot be added does not stop the removals. A group the user is already in, or is not in, counts as done, so a request can be repeated. Members of role-assignable groups cannot be changed. To move a user without leaving them in neither group, add first and remove in a second call once the add succeeded; `Set-InforcerUser` does this when both `-AddGroup` and `-RemoveGroup` are given. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body: [UserGroupsChange](#usergroupschange). + +**Response**: `204` without a body; a change can take a few seconds to show in a GET. Errors: `400` (invalid request, or when some groups were changed and a group refused, a `results` list with each group and whether it was changed), `404` (tenant or user), `502` (a service failed; `results` when some groups were changed). + +#### `POST /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/temporaryAccessPasses` + +Creates a Temporary Access Pass for the user and returns it. The pass is returned only in this response (sent with `Cache-Control: no-store`) and cannot be read again. A user has at most one pass, so a new one replaces any existing pass. The pass then appears in the authentication methods list and can be deleted like any other method. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body (optional): `{ lifetimeInMinutes (10 to 43200), usableOnce, startDateTime }`; a property left out takes the tenant's authentication methods policy default. + +**Response**: `201` with [TemporaryAccessPass](#temporaryaccesspass). Errors: `400` on the property the policy does not allow (lifetime, start in the past, one-time use), or with the reason as `detail` when the policy does not allow a pass for the user at all (for example Temporary Access Pass is off in the tenant); `404` (tenant or user). Policy changes in Microsoft Entra take effect after a short delay. + +#### Mailbox changes: how every write works + +Every mailbox write below is applied by Exchange Online after the response: the answer is `202` with `{ actionId }`, and [`GET .../mailbox/actions/{actionId}`](#get-v1tenantsmstenantidusersuseridmailboxactionsactionid) says when it has succeeded or failed. Changes to one mailbox run one at a time in the order they were accepted, each confirmed in Exchange before the next starts, so allow about a minute per change; an action still waiting an hour after it started fails with `MailboxBusy`. Every request queues a new action, also a repeat, so do not resend while one is queued or running. Repeating a change that is already in place succeeds. Common errors: `400` (also for a Global Administrator's mailbox, and for unknown body properties), `404` (tenant or user), `409`, `502`. A user with no mailbox is accepted with `202`, and the action then fails. `Set-InforcerUser` waits on each action (at most 5 minutes) before its next step. + +**Required API scope(s)** for every mailbox route: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (read for GET, write for the rest) *(unconfirmed)* + +#### `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox` + +The mailbox as Exchange Online holds it now ([Mailbox](#mailbox)). A user with no mailbox is a `404`. `Get-InforcerUser -IncludeMailbox` adds it (with the five lists below) as `mailbox`. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management *(unconfirmed)* + +#### `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox/autoReply` + +The automatic replies in the shape `PATCH` takes, so they can be read, changed and sent back (leave out the properties that are `null`). `simplified: true` means a message had formatting the API cannot keep (a link, table or colour) and is returned without it. `404` when the user has no mailbox. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management *(unconfirmed)* + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/autoReply` + +Turns automatic replies on (`alwaysEnabled`), schedules them (`scheduled`) or turns them off (`disabled`). `status` is always sent; Exchange sets the replies as a whole, so a property left out is not kept. `disabled` takes no other property and keeps the saved messages. Otherwise `internalReplyMessage` and `externalAudience` (`none`, `contactsOnly`, `all`) are needed, `externalReplyMessage` unless the audience is `none`, and `scheduled` needs `scheduledStartDateTime` and `scheduledEndDateTime` (with an offset, end after start and in the future). Messages up to 16000 characters, keeping only bold, italic, underline and text size. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/type` + +Converts the mailbox to a shared mailbox or back to a user mailbox. Body: `{ "type": "shared" }` or `{ "type": "user" }`. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/archive` + +Turns on the mailbox's online archive. Body: `{ "enabled": true }` (JSON Merge Patch; `false` is a `400`, because the archive cannot be turned off here). An archive already on succeeds. Mail moves into the archive under the tenant's retention policy, not straight away. A user synced from on-premises is a `400`. The `archive` property of [Mailbox](#mailbox) shows whether it is on. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/forwarding` and `DELETE` on the same path + +`PATCH` forwards the mail to one user in the tenant (`recipientUserId`) or one address on a verified domain (`smtpAddress`), exactly one of them, with `keepCopy`. Setting one replaces the other. The mailbox's own user or address, a guest, a user with no email address and anything outside the verified domains are a `400`. `DELETE` stops forwarding (to a user and to an address). + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +#### `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses` and `DELETE .../emailAddresses/{address}` + +`POST { address, primary }` adds an address on a domain verified in the tenant; `primary: true` also makes it the main one. `DELETE` removes one; the main and the sign-in address are a `400`, so after changing the main address wait for that action before removing the old one. A user synced from on-premises Active Directory is a `400` for both. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +#### `GET`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions` and `DELETE .../permissions/{permission}/{trusteeId}` + +`GET` lists who holds `fullAccess`, `sendAs` and `sendOnBehalf` (`{ permissions: [...], unreadPermissions: [...] }`, see [Mailbox](#mailbox)); a kind in `unreadPermissions` could not be read just now, so its holders are missing. A failed name lookup is a `502`. `POST { trusteeId, permission, automapping }` grants one to another user in the tenant (`automapping` only with `fullAccess`). `DELETE` removes one; an inherited permission fails, and a holder with `trusteeId` `null` (a group or deleted account) cannot be removed through the API. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (read for GET, write for the rest) *(unconfirmed)* + +#### `GET`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess` and `DELETE .../calendarAccess/{trusteeId}` + +`GET` lists who the calendar is shared with (`{ calendarAccess: [ { trusteeId, displayName, role } ] }`, in no fixed order). `role` is `reviewer` (sees events), `editor` (also creates, changes and deletes them), `delegate` (an editor who also receives meeting requests) or `other` (access set outside inforcer, such as free/busy only; it can be replaced or removed). `trusteeId` is `null` for a holder that is not a user (a group or deleted account), whose access cannot be changed, and also when Exchange could not look the holder up just now. A failed name lookup is a `502`. `POST { trusteeId, role }` shares the calendar with a member of the tenant (a guest or the mailbox's own user is a `400`) or changes the role of someone who already has access. `DELETE` takes the access away whatever the role; removing access the user does not have succeeds. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (read for GET, write for the rest) *(unconfirmed)* + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailApps` + +Allows or blocks the mail apps the mailbox can connect with. The body is a JSON Merge Patch with at least one of `outlookWeb` (also the new Outlook for Windows), `outlookDesktop` (classic Outlook for Windows), `outlookMac` (the new Outlook for Mac), `exchangeWebServices`, `imap`, `pop`, `outlookApp` (iOS and Android) and `otherMailApps` (Exchange ActiveSync), each `true` or `false`; apps left out keep their setting and `null` is refused. A tenant-wide policy can still block an app this allows. The current values are `mailApps` of [Mailbox](#mailbox). `Set-InforcerUser` sends `-AllowMailApp` and `-BlockMailApp` together in one request. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +#### `GET`, `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups` and `DELETE .../mailGroups/{groupId}` + +`GET` lists the distribution lists and mail-enabled security groups the user is a direct member of (`{ mailGroups: [ { id, displayName, mail, type } ] }`, `type` `distributionList` or `mailEnabledSecurity`; Microsoft 365 groups are left out; `404` only when the user is not in the tenant). `POST { groupId }` adds the user, `DELETE` removes them. Microsoft 365 groups, groups without an address and groups synced from on-premises are a `400`. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (read for GET, write for the rest) *(unconfirmed)* + +#### `GET`, `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/inboxRules` and `DELETE .../inboxRules/{ruleId}` + +`GET` lists the inbox rules, with where each forwards or redirects mail (`{ inboxRules: [...] }`, see [Mailbox](#mailbox)). `DELETE ...?all=true` removes every rule Exchange can remove (the junk filter and similar are kept); `DELETE .../{ruleId}` removes one, and a rule with `deletable: false` fails. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (read for GET, write for the rest) *(unconfirmed)* + +#### `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/addressListVisibility` + +Hides the user's mailbox from the address lists, or shows it again. Outlook's address book can take up to 48 hours to show the change. The current value is `hiddenFromAddressList` on [Mailbox](#mailbox). + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +Body (JSON Merge Patch): `{ "hidden": true }` or `{ "hidden": false }`. `hidden` cannot be cleared; other properties are a `400`. + +**Response**: `202` with `{ actionId }`. Errors: `400` (also for a Global Administrator's mailbox), `404` (tenant or user), `409`, `502`. + +There is no list of a user's mailbox actions: the `actionId` is the only way to follow one. + +#### `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox/actions/{actionId}` + +Returns a queued mailbox change and where it has got to, whether it was asked for through the API or in inforcer. `Set-InforcerUser` polls it after every mailbox change (2, 4, 8, then every 15 seconds, at most 5 minutes) until it has succeeded or failed. + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: User & Group Management (write) *(unconfirmed)* + +**Response**: `200` with [MailboxAction](#mailboxaction). `404`: tenant, user or action. ### How v1 fields map to the module's names @@ -433,6 +701,19 @@ Retrieves a specific tenant by ID. --- +#### GET /v1/tenants/{msTenantId}/subscriptions + +Lists the Microsoft products the tenant subscribes to, one entry per SKU with its seats totalled across every subscription to that product. v1 only. + +**Cmdlet**: `Get-InforcerTenant -IncludeSubscriptions` (adds them as `subscriptions`) + +**Required API scope(s)**: not available with an API key (beta). +**Required API client permission(s)**: Tenants *(unconfirmed)* + +**Response**: `{ "subscriptions": [ Subscription ] }` ([Subscription](#subscription)), all in one response. Errors: `404` (tenant), `409` (the request conflicts with the tenant's current state; the spec gives no detail), `502`. + +--- + ### Tenant Policies #### GET /beta/tenants/{tenantId}/policies @@ -854,6 +1135,21 @@ Represents a license associated with a tenant. --- +### Subscription + +One element of `subscriptions` from `GET /v1/tenants/{msTenantId}/subscriptions` (v1 only). Every property is always present. + +| Property | Type | Description | +|----------|------|-------------| +| skuId | string (uuid) | The SKU's id, as `-AddLicense` and `assignLicenses` take it. | +| sku | string, nullable | The part number, such as `SPB`. | +| name | string, nullable | The display name; `null` when there is no known one. | +| capabilityStatus | string | `enabled`, `warning` (grace period after it lapsed), `suspended`, `deleted`, `lockedOut` or `unknown`. camelCase, unlike `capabilityStatus` on a user's licence, which is Microsoft's value as is. | +| appliesTo | string | `user`, `company` (the whole tenant) or `unknown`. | +| units | object | Seats: `enabled` (paid for), `consumed` (assigned), `available` (enabled minus consumed, never below zero), `suspended`, `warning`, `lockedOut`. | + +--- + ### Policy Represents a policy associated with a tenant. @@ -1025,6 +1321,126 @@ License assignment on a user, used in both UserSummary and User schemas. | isCancelled | boolean | Whether the license is cancelled. | | state | string | License assignment state. | +### CreatedUser + +Returned by `POST /v1/tenants/{msTenantId}/users`. `New-InforcerUser` adds `TenantId`, `displayName` and `userPrincipalName` (from the request) so the result can be piped to `Set-InforcerUser`. + +| Property | Type | Description | +|----------|------|-------------| +| id | string (uuid) | The new user's Microsoft Entra object id. | + +### UserUpdate + +The profile fields of `PATCH /v1/tenants/{msTenantId}/users/{userId}` (and of the create body). All optional and nullable unless noted; `null` clears a field. `displayName`, `mailNickname`, `userPrincipalName`, `mail`, `userType` and `accountEnabled` cannot be cleared. Unknown properties are rejected. + +| Property | Type | Limits / notes | +|----------|------|----------------| +| accountEnabled | boolean | `false` blocks sign-in; existing sessions last until their tokens expire. | +| displayName | string | 1-256 characters. | +| mailNickname | string | 1-64 characters. The mail alias. | +| userPrincipalName | string | The sign-in name. | +| givenName, surname | string | 1-64 characters. | +| jobTitle | string | 1-128 characters. | +| department | string | 1-64 characters. | +| officeLocation, city, state, country | string | 1-128 characters. | +| streetAddress | string | 1-1024 characters. | +| postalCode | string | 1-40 characters. | +| mobilePhone, preferredLanguage, companyName, employeeType | string | 1-64 characters. | +| usageLocation | string | Two letters (ISO 3166), such as `GB`. | +| employeeId | string | 1-16 characters. | +| mail | string (email) | | +| businessPhones | string[] | At most one number. | +| otherMails | string[] (email) | | +| managerId | string (uuid) | The manager's object id; `null` removes the manager. | +| userType | string | `Member` or `Guest`. A new user is a `Member` when it is left out. | + +### PasswordReset + +The body of `POST /v1/tenants/{msTenantId}/users/{userId}/password`. + +| Property | Type | Required | Description | +|----------|------|----------|-------------| +| password | string | Yes | The new password; it must meet the tenant's password policy. A blank password is a `400`. | +| forceChangePasswordNextSignIn | boolean | Yes | Whether the user must change the password when they next sign in. `Set-InforcerUser` sends `true` unless you pass `-ForceChangePasswordNextSignIn $false`. | + +### UserLicenseAssignment + +The body of `POST /v1/tenants/{msTenantId}/users/{userId}/assignLicenses`. Send at least one licence. + +| Property | Type | Required | Description | +|----------|------|----------|-------------| +| addSkuIds | string[] (uuid) | No | The `skuId`s to give the user, as in `assignedLicenses`. | +| removeSkuIds | string[] (uuid) | No | The `skuId`s to take from the user. | + +### UserGroupsChange + +The body of `POST /v1/tenants/{msTenantId}/users/{userId}/groups`. At least one group in all, and a group in only one of the lists. + +| Property | Type | Required | Description | +|----------|------|----------|-------------| +| add | string[] (uuid) | No | Object ids of the groups to add the user to, at most 20. A repeated id is ignored. | +| remove | string[] (uuid) | No | Object ids of the groups to remove the user from, at most 20. A repeated id is ignored. | + +### TemporaryAccessPass + +The answer of `POST /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/temporaryAccessPasses`. `Set-InforcerUser -TemporaryAccessPass` returns it with `userId` added. + +| Property | Type | Description | +|----------|------|-------------| +| id | string | The pass's authentication method id, as the authentication methods list returns it. | +| temporaryAccessPass | string | The pass the user signs in with. Returned only here; it cannot be read again. | +| startDateTime | string (date-time), nullable | When the pass becomes usable. | +| lifetimeInMinutes | integer, nullable | How long the pass lasts from `startDateTime`. | +| usableOnce | boolean, nullable | Whether the pass can be used only once. | + +### MailboxAction + +The answer of `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox/actions/{actionId}`. Every property is always present. + +| Property | Type | Description | +|----------|------|-------------| +| actionId | string (uuid) | The action's id, from the `202` that queued it. | +| action | string | The change: `convertToShared`, `convertToUser`, `setAddressListVisibility`, `setAutoReply`, `setForwarding`, `grantPermission`, `removePermission`, `removeInboxRules`, `addToMailGroup`, `removeFromMailGroup`, `addEmailAddress`, `removeEmailAddress`, `setMailApps`, `setCalendarAccess` or `enableArchive`. A change asked for in inforcer can have a value the API cannot ask for. More may be added. | +| status | string | `queued` (waits for an earlier change to the same mailbox), `running`, `succeeded` (Exchange shows the change) or `failed`. | +| queuedBehind | string (uuid), nullable | While `queued`, the action it waits for, when the caller can read that one. | +| requestedAt | string (date-time) | When it was asked for. | +| completedAt | string (date-time), nullable | When it succeeded or failed; `null` before. | +| error | object, nullable | `{ code, message }` once it has failed, such as `WriteNotApplied` or `NotStarted`; otherwise `null`. | + +### Mailbox + +The answer of `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox`. Every property is always present. `Get-InforcerUser -IncludeMailbox` adds `autoReply`, `permissions`, `unreadPermissions`, `calendarAccess`, `mailGroups` and `inboxRules` from the routes of the same names. + +| Property | Type | Description | +|----------|------|-------------| +| displayName | string, nullable | The mailbox's name in Exchange. | +| type | string | `user`, `shared`, `room`, `equipment` or `other` (treat an unknown value as `other`). | +| emailAddresses | array | `{ address, primary }`, the main address first. | +| onPremisesSyncEnabled | boolean | The user is synced from on-premises Active Directory, so addresses and address list visibility are changed there. | +| hiddenFromAddressList | boolean | Hidden from the address lists (set with `addressListVisibility` and its `hidden`). | +| litigationHold | boolean | On litigation hold. | +| size | object, nullable | `{ usedBytes, itemCount, quotaBytes }` (`quotaBytes` `null` = unlimited); `null` when Exchange could not report it. | +| archive | object, nullable | `{ usedBytes }` of the online archive; `null` when there is none. | +| forwarding | object | `{ enabled, recipientUserId, recipientDisplayName, smtpAddress, keepCopy }`. Both targets can be `null` while `enabled` when the recipient is a contact or group. | +| mailApps | object, nullable | `{ outlookWeb, outlookDesktop, outlookMac, exchangeWebServices, imap, pop, outlookApp, otherMailApps }`, each `true` (allowed), `false` (blocked) or `null` (Exchange gives no value; for `exchangeWebServices` the organisation's setting applies). `null` when Exchange could not report them. A tenant-wide policy can still block an allowed app. | + +An element of `permissions`: `{ permission, trusteeId, displayName, inherited }` (`trusteeId` `null` for a holder that is not a user, or one Exchange could not look up just now). An element of `calendarAccess`: `{ trusteeId, displayName, role }`. An element of `inboxRules`: `{ id, name, enabled, description, deletesMessages, hidden, deletable, forwardsExternally, recipients }`, where `recipients` are `{ kind (forward, forwardAsAttachment, redirect), address, displayName, external }`, `forwardsExternally` is `null` when a recipient could not be checked, and `enabled` is `null` for a rule that is not deletable. `autoReply`: `{ status, externalAudience, internalReplyMessage, externalReplyMessage, scheduledStartDateTime, scheduledEndDateTime, simplified }`. + +### UserAuthenticationMethod + +One element of `authenticationMethods` from `GET /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods`. Every property is always present; the ones that do not apply to the type are `null`. + +| Property | Type | Description | +|----------|------|-------------| +| id | string | The method's Microsoft Entra id. Usually a uuid, but not for every type (a passkey's id is not). The password and each phone type have the same id for every user. | +| type | string | `password`, `phone`, `email`, `microsoftAuthenticator`, `passkey`, `windowsHelloForBusiness`, `platformCredential`, `temporaryAccessPass`, `softwareOath`, `hardwareOath`, `qrCodePin`, `externalAuthentication` or `other`. More values may be added; treat an unknown value as `other`. | +| displayName | string \| null | The device or key name, for Microsoft Authenticator, passkeys, Windows Hello for Business, platform credentials and hardware OATH tokens. | +| createdDateTime | string (date-time) \| null | When the method was registered; for `password`, when it was last set. | +| deletable | boolean | Whether inforcer can delete the method. `false` for `password`, `externalAuthentication` and `other`. | +| phoneNumber | string \| null | For a `phone` method. | +| phoneType | string \| null | `mobile`, `alternateMobile` or `office`, for a `phone` method. | +| emailAddress | string \| null | For an `email` method. | + ### TenantGroupSummary Summary of an Entra ID group (returned from list endpoint). diff --git a/docs/CMDLET-REFERENCE.md b/docs/CMDLET-REFERENCE.md index 5a56630..7962021 100644 --- a/docs/CMDLET-REFERENCE.md +++ b/docs/CMDLET-REFERENCE.md @@ -4,7 +4,7 @@ This document describes each cmdlet with parameters, usage examples, and **examp > **Tip**: For detailed property definitions and API schemas, see the [API Reference](./API-REFERENCE.md). -> **Logins**: every cmdlet works with both logins. An API client (`Connect-Inforcer -ClientId -ClientSecret`) uses the v1 API; an API key (`-ApiKey`) uses the legacy beta API. Each cmdlet lists the beta API-key scopes and the v1 API client permissions it needs. The v1 permission mapping is unconfirmed (see [API client permissions](./API-REFERENCE.md#api-client-permissions-v1)). Tenant IDs: Microsoft tenant ID (GUID) or name on both logins; the numeric Client Tenant ID only with an API key. `-TenantId` has the aliases `ClientTenantId` and `MsTenantId`. +> **Logins**: every cmdlet works with both logins, except `New-InforcerUser` and `Set-InforcerUser`, which need an API client because the beta API cannot create or change users. An API client (`Connect-Inforcer -ClientId -ClientSecret`) uses the v1 API; an API key (`-ApiKey`) uses the legacy beta API. Each cmdlet lists the beta API-key scopes and the v1 API client permissions it needs. The v1 permission mapping is unconfirmed (see [API client permissions](./API-REFERENCE.md#api-client-permissions-v1)). Tenant IDs: Microsoft tenant ID (GUID) or name on both logins; the numeric Client Tenant ID only with an API key. `-TenantId` has the aliases `ClientTenantId` and `MsTenantId`. > **Note**: Default output shows key properties. Use `| Select-Object *` to see all properties including raw API fields. @@ -12,7 +12,7 @@ This document describes each cmdlet with parameters, usage examples, and **examp ## Personal data -User details (`Get-InforcerUser -UserId`), audit events, report outputs and the files written by `Export-InforcerTenantDocumentation`, `Compare-InforcerEnvironments`, `Invoke-InforcerAssessment`, `Invoke-InforcerReport` and `Save-InforcerReportOutput` can contain personal data (names, UPNs, email addresses, IP addresses, sign-in details). The module caches no user or audit data and writes files only where you ask (`-OutputPath`, or the current directory for `Invoke-InforcerReport` and `Save-InforcerReportOutput`). Handle exported files as personal data. +User details (`Get-InforcerUser -UserId`, including the phone numbers and email addresses that `-IncludeAuthenticationMethods` adds), audit events, report outputs and the files written by `Export-InforcerTenantDocumentation`, `Compare-InforcerEnvironments`, `Invoke-InforcerAssessment`, `Invoke-InforcerReport` and `Save-InforcerReportOutput` can contain personal data (names, UPNs, email addresses, IP addresses, sign-in details). The module caches no user or audit data and writes files only where you ask (`-OutputPath`, or the current directory for `Invoke-InforcerReport` and `Save-InforcerReportOutput`). Handle exported files as personal data. --- @@ -154,19 +154,21 @@ Retrieves tenant information. Optionally filter by `-TenantId` (Microsoft Tenant - **Both logins:** the list holds every field (licenses, `SecureScore`, `IsBaseline`, tags, alignment summaries, `LastBackupTimestamp`). - **Client-credentials login (v1):** `ClientTenantId` does not exist. `-TenantId` loads the tenant's own record, which adds `AuthenticationMode`; `-TenantId ` makes only that one call, a name is first looked up in the tenant list. - **`-TenantId` always returns the current record:** with an API key the tenant list is fetched once per call (piped tenants share that fetch); with client credentials the tenant is fetched by id. +- **Subscriptions (client credentials only):** `-IncludeSubscriptions` adds `subscriptions`, the tenant's licences with their `skuId` (for `Set-InforcerUser -AddLicense`), name, status and seats (`units.enabled`, `units.consumed`, `units.available`, ...). One extra request per tenant; with an API key it stops with `RequiresApiClient`. A tenant whose subscriptions cannot be read is still returned, without `subscriptions`, next to the error. - **JSON:** with client credentials `-OutputType JsonObject` is always a JSON array, also for one tenant. With an API key a single tenant is a bare JSON object, as in 0.8.0. **Endpoints called (beta)**: `GET /beta/tenants` **Required API scope(s) (API key, beta)**: `Tenants.Read` -**Endpoints on v1**: `GET /v1/tenants`; `-TenantId ` calls only `GET /v1/tenants/{msTenantId}` (a name also reads the tenant list) +**Endpoints on v1**: `GET /v1/tenants`; `-TenantId ` calls only `GET /v1/tenants/{msTenantId}` (a name also reads the tenant list); `-IncludeSubscriptions` adds `GET /v1/tenants/{msTenantId}/subscriptions` per tenant **Required API client permission(s) (v1)**: Tenants *(unconfirmed, see [API client permissions](./API-REFERENCE.md#api-client-permissions-v1))* -**Output schema**: [Tenant](./API-REFERENCE.md#tenant) — includes `licenses`, `PolicyDiff` +**Output schema**: [Tenant](./API-REFERENCE.md#tenant) — includes `licenses`, `PolicyDiff`; with `-IncludeSubscriptions` also `subscriptions` ([Subscription](./API-REFERENCE.md#subscription)) | Parameter | Type | Mandatory | Description | |-----------|------|-----------|--------------| | **Format** | String | No | `Raw` (default). | | **TenantId** | Object | No | Filter to this tenant: Microsoft tenant ID (GUID), tenant name or DNS name; numeric Client Tenant ID with an API key only. Aliases: `ClientTenantId`, `MsTenantId`. | +| **IncludeSubscriptions** | Switch | No | Adds `subscriptions` (licences with `skuId` and free seats). API client login only. | | **OutputType** | String | No | `PowerShellObject` (default) or `JsonObject`. JSON uses Depth 100. | ### Examples @@ -176,6 +178,8 @@ Get-InforcerTenant Get-InforcerTenant | Where-Object IsBaseline Get-InforcerTenant -TenantId 'Contoso' Get-InforcerTenant -TenantId 102 # API key only (numeric Client Tenant ID) +# Licences of Contoso with a free seat (client credentials only) +(Get-InforcerTenant -TenantId 'Contoso' -IncludeSubscriptions).subscriptions | Where-Object { $_.units.available -gt 0 } | Select-Object name, skuId, @{ n = 'free'; e = { $_.units.available } } Get-InforcerTenant -OutputType JsonObject ``` @@ -207,6 +211,15 @@ The default view shows 8 key properties. Use `| Select-Object *` to see all prop Same shape as one of the objects above (one tenant). With client credentials it has no `ClientTenantId` and adds `AuthenticationMode`. +### Example output — free seats with -IncludeSubscriptions + +``` +name skuId free +---- ----- ---- +Microsoft 365 E5 00000000-0000-0000-0000-0000000000c1 5 +Exchange Online (Plan 1) 00000000-0000-0000-0000-0000000000c2 12 +``` + --- ## Get-InforcerBaseline @@ -468,9 +481,9 @@ The default view shows 9 key properties. Use `| Select-Object *` to see all prop ## Get-InforcerUser -Retrieves users from an inforcer tenant. Without `-UserId`, returns a paginated list of user summaries with optional search filtering. With `-UserId`, returns the full user detail including groups, roles, devices, and risk information. +Retrieves users from an inforcer tenant. Without `-UserId`, returns a paginated list of user summaries with optional search filtering. With `-UserId`, returns the full user detail including groups, roles, devices, and risk information. Add `-IncludeAuthenticationMethods` (API client only) to get the sign-in methods the user has registered as `authenticationMethods`, and `-IncludeMailbox` (API client only) to get their Exchange Online mailbox as `mailbox`. -> **Personal data:** `-UserId` returns a full personal record. See [Personal data](#personal-data). +> **Personal data:** `-UserId` returns a full personal record; `-IncludeAuthenticationMethods` adds phone numbers and email addresses; `-IncludeMailbox` adds automatic reply texts, forwarding targets and who can read the mailbox. See [Personal data](#personal-data). > **v1:** the list view returns `Groups` and `Roles` as counts (`groupCount`/`roleCount` mapped to those names), not arrays; `-UserId` returns the full record. @@ -478,10 +491,10 @@ Retrieves users from an inforcer tenant. Without `-UserId`, returns a paginated **Endpoints called (beta)**: `GET /beta/tenants/{tenantId}/users` (list) or `GET /beta/tenants/{tenantId}/users/{userId}` (detail) — plus `GET /beta/tenants` when `-TenantId` is a GUID or name (resolution). **Required API scope(s) (API key, beta)**: `Tenants.Users.Read` + `Tenants.Read` *(the `Tenants.Read` part can be skipped if `-TenantId` is always passed as a numeric Client Tenant ID — no lookup needed)* -**Endpoints on v1**: `GET /v1/tenants/{msTenantId}/users[/{userId}]` +**Endpoints on v1**: `GET /v1/tenants/{msTenantId}/users[/{userId}]`, `GET /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods` (with `-IncludeAuthenticationMethods`), `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox`, `.../mailbox/autoReply`, `.../mailbox/permissions`, `.../mailbox/calendarAccess`, `.../mailbox/mailGroups`, `.../mailbox/inboxRules` (with `-IncludeMailbox`) **Required API client permission(s) (v1)**: User & Group Management + Tenants (only for a tenant name) *(unconfirmed, see [API client permissions](./API-REFERENCE.md#api-client-permissions-v1))* -**Output schemas**: [UserSummary](./API-REFERENCE.md#usersummary) (list) | [User](./API-REFERENCE.md#user) (detail) +**Output schemas**: [UserSummary](./API-REFERENCE.md#usersummary) (list) | [User](./API-REFERENCE.md#user) (detail) | [UserAuthenticationMethod](./API-REFERENCE.md#userauthenticationmethod) (`authenticationMethods`) | [Mailbox](./API-REFERENCE.md#mailbox) (`mailbox`) | Parameter | Type | Mandatory | ParameterSet | Description | |-----------|------|-----------|--------------|-------------| @@ -490,6 +503,8 @@ Retrieves users from an inforcer tenant. Without `-UserId`, returns a paginated | **Search** | String | No | List | Server-side search filter for the user list. | | **MaxResults** | Int | No | List | Max users to return. 0 = no limit. Default: 0. | | **UserId** | String | Yes | ById | The user ID (GUID) to retrieve full details for. | +| **IncludeAuthenticationMethods** | Switch | No | ById | Adds `authenticationMethods`: the user's registered sign-in methods (password, phone, Microsoft Authenticator, passkey, ...), one extra request. Passwords and Temporary Access Pass codes are never returned. Needs an API client; an API key stops with `RequiresApiClient`. | +| **IncludeMailbox** | Switch | No | ById | Adds `mailbox`: type, size, archive, litigation hold, email addresses, `hiddenFromAddressList`, forwarding and `mailApps`, plus `autoReply`, `permissions`, `unreadPermissions`, `calendarAccess`, `mailGroups` and `inboxRules` (six extra requests). `$null` when the user has no mailbox. Needs an API client. | | **OutputType** | String | No | Both | `PowerShellObject` (default) or `JsonObject`. JSON uses Depth 100. | ### Examples @@ -499,6 +514,10 @@ Get-InforcerUser -TenantId 'Contoso' Get-InforcerUser -TenantId 'Contoso' -Search "Adele" Get-InforcerUser -TenantId 'Contoso' -MaxResults 50 Get-InforcerUser -TenantId 'Contoso' -UserId "00000000-0000-0000-0000-000000000005" +(Get-InforcerUser -TenantId 'Contoso' -UserId "00000000-0000-0000-0000-000000000005" -IncludeAuthenticationMethods).authenticationMethods +# Where the mail goes: forwarding and inbox rules that send mail outside the tenant +$mailbox = (Get-InforcerUser -TenantId 'Contoso' -UserId "00000000-0000-0000-0000-000000000005" -IncludeMailbox).mailbox +$mailbox.forwarding; $mailbox.inboxRules | Where-Object forwardsExternally Get-InforcerTenant -TenantId 'Contoso' | Get-InforcerUser Get-InforcerUser -TenantId 'Contoso' -OutputType JsonObject ``` @@ -530,6 +549,216 @@ IsMfaRegistered : False RiskLevel : ``` +### Example output — authentication methods + +```powershell +(Get-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -IncludeAuthenticationMethods).authenticationMethods | + Format-Table type, displayName, phoneType, deletable, createdDateTime +``` + +``` +type displayName phoneType deletable createdDateTime +---- ----------- --------- --------- --------------- +password False 01/09/2026 09:00:00 +phone mobile True +microsoftAuthenticator Contoso Phone True 02/09/2026 10:15:00 +``` + +### Example output — mailbox + +```powershell +(Get-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -IncludeMailbox).mailbox +``` + +``` +displayName : Jo Bloggs +type : user +emailAddresses : {@{address=jo.bloggs@contoso.com; primary=True}, @{address=jo@contoso.com; primary=False}} +onPremisesSyncEnabled : False +hiddenFromAddressList : False +litigationHold : False +size : @{usedBytes=1073741824; itemCount=5120; quotaBytes=53687091200} +archive : +forwarding : @{enabled=False; recipientUserId=; recipientDisplayName=; smtpAddress=; keepCopy=False} +mailApps : @{outlookWeb=True; outlookDesktop=True; outlookMac=True; exchangeWebServices=; imap=False; pop=False; outlookApp=True; otherMailApps=True} +autoReply : @{status=disabled; externalAudience=none; internalReplyMessage=; externalReplyMessage=; scheduledStartDateTime=; scheduledEndDateTime=; simplified=False} +permissions : {@{permission=fullAccess; trusteeId=00000000-0000-0000-0000-000000000006; displayName=Sam Taylor; inherited=False}} +unreadPermissions : {} +calendarAccess : {@{trusteeId=00000000-0000-0000-0000-000000000006; displayName=Sam Taylor; role=reviewer}} +mailGroups : {@{id=00000000-0000-0000-0000-0000000000c1; displayName=Sales; mail=sales@contoso.com; type=distributionList}} +inboxRules : {} +``` + +--- + +## New-InforcerUser + +Creates a Microsoft Entra user in a tenant. Needs a login with an API client (`Connect-Inforcer -ClientId -ClientSecret`); with an API key it stops with the error `RequiresApiClient`, because the beta API cannot create users. + +The user can sign in by default and must change the password at the first sign-in. `-MailNickname` defaults to the part of `-UserPrincipalName` before the `@`. The password must meet the tenant's password policy; it is sent only in the request body and never written to verbose output. `Get-InforcerUser` can take up to about five minutes to show the new user, because the API caches users. Supports `-WhatIf` and `-Confirm`. + +**Endpoints called (beta)**: none (not available on the beta API). +**Required API scope(s) (API key, beta)**: not available with an API key. +**Endpoints on v1**: `POST /v1/tenants/{msTenantId}/users` (+ `GET /v1/tenants` for a tenant name) +**Required API client permission(s) (v1)**: User & Group Management (write) + Tenants (only for a tenant name) *(unconfirmed, see [API client permissions](./API-REFERENCE.md#api-client-permissions-v1))* + +**Output schema**: [CreatedUser](./API-REFERENCE.md#createduser), with `TenantId`, `displayName` and `userPrincipalName` added. + +| Parameter | Type | Mandatory | Description | +|-----------|------|-----------|-------------| +| **TenantId** | Object | Yes | Microsoft tenant ID (GUID) or tenant name. Aliases: `ClientTenantId`, `MsTenantId`. Supports pipeline input by property name. | +| **DisplayName** | String | Yes | The name shown for the user. | +| **UserPrincipalName** | String | Yes | The sign-in name, such as `jo.bloggs@contoso.com`. The domain must be verified in the tenant. | +| **Password** | SecureString | Yes | The initial password. | +| **MailNickname** | String | No | The mail alias. Default: the part of `-UserPrincipalName` before the `@`. | +| **ForceChangePasswordNextSignIn** | Bool | No | Whether the user must change the password at the first sign-in. Default: `$true`. | +| **AccountEnabled** | Bool | No | Whether the user can sign in. Default: `$true`. | +| **GivenName**, **Surname**, **JobTitle**, **Department**, **OfficeLocation**, **StreetAddress**, **City**, **State**, **PostalCode**, **Country**, **MobilePhone**, **PreferredLanguage**, **CompanyName**, **EmployeeId**, **EmployeeType**, **Mail** | String | No | Profile fields, sent as given. | +| **UsageLocation** | String | No | Two-letter country code (ISO 3166) where the user's licences are used, such as `GB`. Needed before licences can be assigned. | +| **BusinessPhones** | String[] | No | Business phone number. Microsoft Entra allows one. | +| **OtherMails** | String[] | No | Other email addresses. | +| **ManagerId** | String | No | The Microsoft Entra object id of the user's manager. | +| **UserType** | String | No | `Member` (the default when left out) or `Guest`. | +| **OutputType** | String | No | `PowerShellObject` (default) or `JsonObject`. JSON uses Depth 100; piped tenants return one array. | + +### Examples + +```powershell +$password = Read-Host -AsSecureString -Prompt 'Initial password' +New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password +New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password -GivenName 'Jo' -Surname 'Bloggs' -Department 'Sales' -UsageLocation 'GB' -AccountEnabled $false +New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password -WhatIf +New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password -OutputType JsonObject +``` + +### Example output + +``` +DisplayName : Jo Bloggs +UserPrincipalName : jo.bloggs@contoso.com +Id : 00000000-0000-0000-0000-000000000005 +TenantId : 00000000-0000-0000-0000-000000000001 +``` + +--- + +## Set-InforcerUser + +Updates a Microsoft Entra user's profile, manager or whether they can sign in, resets their password, changes their licences or group memberships, changes their Exchange Online mailbox (shared or user, online archive, address lists, email addresses, automatic replies, forwarding, permissions, calendar sharing, mail groups, inbox rules, mail apps), removes registered sign-in methods or resets MFA, issues a Temporary Access Pass, or signs them out of every session. Needs a login with an API client (`Connect-Inforcer -ClientId -ClientSecret`); with an API key it stops with the error `RequiresApiClient`, because the beta API cannot change users. + +Only the parameters you pass are changed; every other field stays as it is. Pass an empty string (`''`) or `$null` to clear a field, such as `-JobTitle ''`, or `-ManagerId ''` to remove the manager. `DisplayName`, `MailNickname`, `UserPrincipalName`, `Mail` and `UserType` cannot be cleared. `-AccountEnabled $false` blocks sign-in, but existing sessions last until their tokens expire. `Get-InforcerUser` can show the old values for up to about five minutes, because the API caches users. Returns nothing, except the pass with `-TemporaryAccessPass`. Supports `-WhatIf` and `-Confirm`. + +When the manager could not be changed but the other changes were saved (HTTP 502), the error lists each step and whether it was applied, for example `Steps: profile: succeeded; manager: failed (Manager not found)`. + +`-Password` sets a new password; the user must change it at the next sign-in unless you pass `-ForceChangePasswordNextSignIn $false`. The password is sent only in the request body and never written to verbose output. `-RevokeSessions` signs the user out of every session; access tokens already issued stay valid until they expire, typically within 90 minutes. `-RemoveAuthenticationMethod` deletes sign-in methods by their `id` from `Get-InforcerUser -IncludeAuthenticationMethods`; only methods with `deletable` true can go, and Microsoft Entra can still refuse one, such as the default method while another phone remains. `-ResetMfa` deletes every deletable method in one request, in the order Microsoft Entra needs, so the user must register MFA again; the password is kept. `-AddLicense`/`-RemoveLicense` change licences by `skuId` in one request; if one is refused, nothing changes. `-AddGroup`/`-RemoveGroup` change Microsoft Entra group memberships; adding runs first and removing only after every add succeeded, so a user moved between groups is never left in neither, and a group the user is already in (or not in) counts as done. `-TemporaryAccessPass` creates a Temporary Access Pass and returns it (shown only once; it replaces an existing pass). Mailbox changes (`-MailboxType`, `-EnableArchive`, `-HiddenFromAddressLists`, `-AddEmailAddress`, `-PrimaryEmailAddress`, `-RemoveEmailAddress`, `-AutoReply`, `-ForwardTo`/`-RemoveForwarding`, `-GrantMailboxPermission`/`-RemoveMailboxPermission`, `-GrantCalendarAccess`/`-RemoveCalendarAccess`, `-AddMailGroup`/`-RemoveMailGroup`, `-RemoveInboxRule`/`-RemoveAllInboxRules`, `-AllowMailApp`/`-BlockMailApp`) are queued in Exchange Online, which applies one change to a mailbox at a time, about a minute each; the cmdlet waits for each with a progress bar until it has succeeded or failed (at most 5 minutes, then it warns with the action id that Exchange carries on) before the next step. Outlook's address book can take up to 48 hours to show a hidden mailbox. One call runs its steps in this order: profile update, licences (when `-AddLicense` is given), adding to groups, removing from groups, mailbox type, online archive, address lists, adding email addresses, primary address, removing email addresses, automatic replies, forwarding, mailbox permissions (grant, then remove), calendar sharing (share, then unshare), mail groups (add, then remove), inbox rules, mail apps (one change for all), licences (when only `-RemoveLicense` is given, so a mailbox is converted to shared before its licence goes), password reset, removing sign-in methods (one request each), MFA reset, Temporary Access Pass, sign-out. When a step fails, the later steps are skipped and the error `UserUpdatePartlyApplied` says which steps were already done and which were not. + +**Pipeline:** users from `Get-InforcerUser` or `New-InforcerUser` can be piped in; `-UserId` binds from their `id` and `-TenantId` from their `TenantId` when they have one. + +**Endpoints called (beta)**: none (not available on the beta API). +**Required API scope(s) (API key, beta)**: not available with an API key. +**Endpoints on v1**: `PATCH /v1/tenants/{msTenantId}/users/{userId}` (profile fields), `POST /v1/tenants/{msTenantId}/users/{userId}/assignLicenses` (`-AddLicense`/`-RemoveLicense`), `POST /v1/tenants/{msTenantId}/users/{userId}/groups` (`-AddGroup`, then `-RemoveGroup`), `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/type` (`-MailboxType`), `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/archive` (`-EnableArchive`), `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/addressListVisibility` (`-HiddenFromAddressLists`), `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses` (`-AddEmailAddress`, `-PrimaryEmailAddress`), `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/emailAddresses/{address}` (`-RemoveEmailAddress`), `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/autoReply` (`-AutoReply`), `PATCH`/`DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/forwarding` (`-ForwardTo`/`-RemoveForwarding`), `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions` and `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/permissions/{permission}/{trusteeId}` (`-GrantMailboxPermission`/`-RemoveMailboxPermission`), `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess` and `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/calendarAccess/{trusteeId}` (`-GrantCalendarAccess`/`-RemoveCalendarAccess`), `POST /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups` and `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailGroups/{groupId}` (`-AddMailGroup`/`-RemoveMailGroup`), `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/inboxRules/{ruleId}` and `DELETE /v1/tenants/{msTenantId}/users/{userId}/mailbox/inboxRules?all=true` (`-RemoveInboxRule`/`-RemoveAllInboxRules`), `PATCH /v1/tenants/{msTenantId}/users/{userId}/mailbox/mailApps` (`-AllowMailApp`/`-BlockMailApp`), each followed by `GET /v1/tenants/{msTenantId}/users/{userId}/mailbox/actions/{actionId}` until done, `POST /v1/tenants/{msTenantId}/users/{userId}/password` (`-Password`), `DELETE /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/{methodId}` (`-RemoveAuthenticationMethod`), `DELETE /v1/tenants/{msTenantId}/users/{userId}/mfa` (`-ResetMfa`), `POST /v1/tenants/{msTenantId}/users/{userId}/authenticationMethods/temporaryAccessPasses` (`-TemporaryAccessPass`), `POST /v1/tenants/{msTenantId}/users/{userId}/revokeSessions` (`-RevokeSessions`) (+ `GET /v1/tenants` for a tenant name) +**Required API client permission(s) (v1)**: User & Group Management (write) + Tenants (only for a tenant name) *(unconfirmed, see [API client permissions](./API-REFERENCE.md#api-client-permissions-v1))* + +**Request schemas**: [UserUpdate](./API-REFERENCE.md#userupdate) | [PasswordReset](./API-REFERENCE.md#passwordreset) | [UserLicenseAssignment](./API-REFERENCE.md#userlicenseassignment) | [UserGroupsChange](./API-REFERENCE.md#usergroupschange) +**Polled schema** (after every mailbox change): [MailboxAction](./API-REFERENCE.md#mailboxaction) +**Output schema** (with `-TemporaryAccessPass`): [TemporaryAccessPass](./API-REFERENCE.md#temporaryaccesspass) + +| Parameter | Type | Mandatory | Description | +|-----------|------|-----------|-------------| +| **TenantId** | Object | Yes | Microsoft tenant ID (GUID) or tenant name. Aliases: `ClientTenantId`, `MsTenantId`. Supports pipeline input by property name. | +| **UserId** | String | Yes | The user's Microsoft Entra object id. Alias: `Id`. Supports pipeline input by property name. | +| **AccountEnabled** | Bool | No | Whether the user can sign in. | +| **DisplayName**, **MailNickname**, **UserPrincipalName**, **Mail** | String | No | Cannot be cleared; an empty value is refused. | +| **GivenName**, **Surname**, **JobTitle**, **Department**, **OfficeLocation**, **StreetAddress**, **City**, **State**, **PostalCode**, **Country**, **MobilePhone**, **UsageLocation**, **PreferredLanguage**, **CompanyName**, **EmployeeId**, **EmployeeType** | String | No | Profile fields; `''` clears the field. | +| **BusinessPhones**, **OtherMails** | String[] | No | Replace the whole list; `@()` clears it. | +| **ManagerId** | String | No | The manager's Microsoft Entra object id; `''` removes the manager. | +| **UserType** | String | No | `Member` or `Guest`. Cannot be cleared. | +| **AddLicense** | Guid[] | No | `skuId`s of licences to give the user (from `Get-InforcerTenant -IncludeSubscriptions`, which also shows free seats, or `assignedLicenses` of `Get-InforcerUser -UserId`). The user needs a usage location. | +| **RemoveLicense** | Guid[] | No | `skuId`s of licences to take from the user. A licence given through a group is refused. | +| **AddGroup** | Guid[] | No | Object ids of Microsoft Entra groups (at most 20) to add the user to. Role-assignable groups are refused. | +| **RemoveGroup** | Guid[] | No | Object ids of Microsoft Entra groups (at most 20) to remove the user from; runs only after `-AddGroup` succeeded. | +| **HiddenFromAddressLists** | Bool | No | `$true` hides the mailbox from the address lists, `$false` shows it again. Waits until Exchange Online has applied it (at most 5 minutes). A Global Administrator's mailbox is refused. | +| **MailboxType** | String | No | `User` or `Shared`. Converts the mailbox, for a leaver before the licence is removed. | +| **EnableArchive** | Switch | No | Turns on the online archive. It cannot be turned off here; mail moves into it under the tenant's retention policy. Refused for a user synced from on-premises. | +| **AutoReply** | Object | No | Hashtable, or the `autoReply` from `Get-InforcerUser -IncludeMailbox` (nulls and `simplified` are left out): `status` (`disabled`, `alwaysEnabled`, `scheduled`), `internalReplyMessage`, `externalAudience` (`none`, `contactsOnly`, `all`), `externalReplyMessage`, `scheduledStartDateTime`, `scheduledEndDateTime`. Exchange sets the replies as a whole; with `disabled` only `status` is sent. | +| **ForwardTo** | String | No | A user's object id in the tenant, or an address on a verified domain. Replaces earlier forwarding. | +| **KeepForwardedCopy** | Switch | No | Keeps a copy of forwarded mail. Only with `-ForwardTo` (else `ForwardToRequired`). | +| **RemoveForwarding** | Switch | No | Stops forwarding. Not with `-ForwardTo` (`ConflictingForwarding`). | +| **GrantMailboxPermission** | Object[] | No | Each `@{ permission = 'fullAccess'\|'sendAs'\|'sendOnBehalf'; trusteeId = ''; automapping = $true }` (`automapping` only for `fullAccess`). Missing keys stop with `InvalidMailboxPermission`. | +| **RemoveMailboxPermission** | Object[] | No | Each with `permission` and `trusteeId`, such as entries of `mailbox.permissions`. Inherited ones cannot be removed. | +| **GrantCalendarAccess** | Object[] | No | Each `@{ trusteeId = ''; role = 'reviewer'\|'editor'\|'delegate' }`: share the calendar with a member of the tenant (not a guest), or change their role. A missing id or other role stops with `InvalidCalendarAccess`. | +| **RemoveCalendarAccess** | Guid[] | No | Object ids of users whose calendar access is taken away, whatever their role (`trusteeId` of `mailbox.calendarAccess`). | +| **AddMailGroup**, **RemoveMailGroup** | Guid[] | No | Object ids of distribution lists or mail-enabled security groups. Microsoft 365 groups and on-premises groups are refused. | +| **AddEmailAddress** | String[] | No | Addresses to add, on domains verified in the tenant. | +| **PrimaryEmailAddress** | String | No | Adds the address if needed and makes it the main one, before `-RemoveEmailAddress` runs. | +| **RemoveEmailAddress** | String[] | No | Addresses to remove; the main and sign-in address are refused. | +| **RemoveInboxRule** | String[] | No | Ids from `mailbox.inboxRules`; rules with `deletable` false fail. | +| **RemoveAllInboxRules** | Switch | No | Removes every rule Exchange can remove (the junk filter and similar stay). | +| **AllowMailApp**, **BlockMailApp** | String[] | No | Mail apps to allow or block: `OutlookWeb` (also the new Outlook for Windows), `OutlookDesktop` (classic Outlook for Windows), `OutlookMac`, `ExchangeWebServices`, `Imap`, `Pop`, `OutlookApp` (iOS and Android), `OtherMailApps` (Exchange ActiveSync). Sent as one change; apps not named keep their setting. A tenant-wide policy can still block an allowed app. The same app in both stops with `ConflictingMailApp`. | +| **Password** | SecureString | No | A new password. It must meet the tenant's password policy. | +| **ForceChangePasswordNextSignIn** | Bool | No | Whether the user must change the new password at the next sign-in. Default: `$true`. Only with `-Password`; on its own it stops with `PasswordRequired`. | +| **RemoveAuthenticationMethod** | String[] | No | Ids of registered sign-in methods to delete, from `authenticationMethods` of `Get-InforcerUser -IncludeAuthenticationMethods`. Only methods with `deletable` true. | +| **ResetMfa** | Switch | No | Deletes every deletable sign-in method, so the user must register MFA again. The password is kept. | +| **TemporaryAccessPass** | Switch | No | Creates a Temporary Access Pass and returns it. Runs after `-ResetMfa`. | +| **TemporaryAccessPassLifetime** | Int | No | Minutes, 10 to 43200 (and within the tenant's policy). Only with `-TemporaryAccessPass`. | +| **TemporaryAccessPassUsableOnce** | Bool | No | Whether the pass works only once. Only with `-TemporaryAccessPass`. | +| **RevokeSessions** | Switch | No | Signs the user out of every session. | + +At least one field, `-AddLicense`, `-RemoveLicense`, a mailbox change, `-Password`, `-RemoveAuthenticationMethod`, `-ResetMfa`, `-TemporaryAccessPass` or `-RevokeSessions` must be passed; otherwise the cmdlet stops with `NoChangeSpecified` without a request. + +### Examples + +```powershell +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -Department 'Sales' -JobTitle 'Account Manager' +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false -RevokeSessions +$password = Read-Host -AsSecureString -Prompt 'New password' +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -Password $password -RevokeSessions +# Lock out a compromised account: new password, every removable sign-in method deleted, signed out everywhere +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -Password $password -ResetMfa -RevokeSessions +# New sign-in methods after an MFA reset: one-time pass, valid for an hour +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -ResetMfa -TemporaryAccessPass -TemporaryAccessPassLifetime 60 -TemporaryAccessPassUsableOnce $true +# Licence: set the usage location, then give the licence +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -UsageLocation 'GB' -AddLicense '00000000-0000-0000-0000-0000000000b1' +# Offboard a leaver: block sign-in, hide the mailbox from the address book, end every session +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false -HiddenFromAddressLists $true -RevokeSessions +# Offboard and keep the mail: shared mailbox, automatic reply, manager gets full access, then the licence goes +$reply = @{ status = 'alwaysEnabled'; externalAudience = 'all'; internalReplyMessage = 'Jo has left Contoso. Please contact sales@contoso.com.'; externalReplyMessage = 'Jo has left Contoso. Please contact sales@contoso.com.' } +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false -MailboxType Shared -AutoReply $reply -GrantMailboxPermission @{ permission = 'fullAccess'; trusteeId = '00000000-0000-0000-0000-000000000006' } -RemoveLicense '00000000-0000-0000-0000-0000000000b1' -RevokeSessions +# Compromised mailbox: stop forwarding and remove the inbox rules that send mail outside the tenant +$mailbox = (Get-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -IncludeMailbox).mailbox +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -RemoveForwarding -RemoveInboxRule @($mailbox.inboxRules | Where-Object forwardsExternally).id +# Block IMAP and POP and make a colleague a delegate of the calendar +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -BlockMailApp Imap, Pop -GrantCalendarAccess @{ trusteeId = '00000000-0000-0000-0000-000000000006'; role = 'delegate' } +# Move the user to another group: added to the new one first, then removed from the old one +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AddGroup '00000000-0000-0000-0000-0000000000c2' -RemoveGroup '00000000-0000-0000-0000-0000000000c1' +# New main address, old one removed in the same call +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -PrimaryEmailAddress 'jo.bloggs@contoso.com' -RemoveEmailAddress 'jo@contoso.com' +# Remove one lost phone, keep the other sign-in methods +$user = Get-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -IncludeAuthenticationMethods +Set-InforcerUser -TenantId 'Contoso' -UserId $user.id -RemoveAuthenticationMethod @($user.authenticationMethods | Where-Object phoneNumber -eq '+44 7700 900000').id +Get-InforcerUser -TenantId 'Contoso' -Search 'Adele' | Set-InforcerUser -TenantId 'Contoso' -ManagerId '' +Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -UsageLocation 'GB' -WhatIf +``` + +### Example output + +With `-TemporaryAccessPass`: + +``` +id : 00000000-0000-0000-0000-0000000000c1 +temporaryAccessPass : Ab3#kq7P +startDateTime : 2026-11-15T10:00:00+00:00 +lifetimeInMinutes : 60 +usableOnce : True +userId : 00000000-0000-0000-0000-000000000005 +``` + +Otherwise none. With `-WhatIf`: + +``` +What if: Performing the operation "Update usageLocation" on target "user 00000000-0000-0000-0000-000000000005 in tenant 00000000-0000-0000-0000-000000000001". +``` + --- ## Get-InforcerGroup diff --git a/docs/openapi-snapshot-v1.json b/docs/openapi-snapshot-v1.json index c49aa4d..45e0390 100644 --- a/docs/openapi-snapshot-v1.json +++ b/docs/openapi-snapshot-v1.json @@ -1,3066 +1,3123 @@ { - "openapi": "3.0.4", - "info": { - "title": "inforcer | Public API", - "version": "1.0.0" - }, - "paths": { - "/v1/tenants": { - "get": { - "tags": [ - "Tenants" - ], - "summary": "List tenants", - "description": "Lists the tenants in the API client's tenant scope", - "operationId": "listTenants", - "responses": { - "200": { - "description": "The tenants", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/tenantList" - } - } + "components": { + "responses": { + "badGateway": { + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" } - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" - }, - "429": { - "$ref": "#/components/responses/tooManyRequests" } - } - } - }, - "/v1/tenants/{msTenantId}": { - "get": { - "tags": [ - "Tenants" - ], - "summary": "Get tenant", - "description": "Returns a tenant in the API client's tenant scope", - "operationId": "getTenant", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, + }, + "description": "A service the request depends on failed" + }, + "badRequest": { + "content": { + "application/problem+json": { "schema": { - "$ref": "#/components/schemas/msTenantId" + "$ref": "#/components/schemas/validationProblem" } } - ], - "responses": { - "200": { - "description": "The tenant", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/tenantDetail" - } - } + }, + "description": "The request is invalid" + }, + "conflict": { + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" } - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" - }, - "404": { - "$ref": "#/components/responses/notFound" - }, - "409": { - "$ref": "#/components/responses/conflict" - }, - "429": { - "$ref": "#/components/responses/tooManyRequests" } - } - } - }, - "/v1/tenants/{msTenantId}/policies": { - "get": { - "tags": [ - "Policies" - ], - "summary": "List tenant policies", - "description": "Lists the policies of a tenant in the API client's tenant scope, in inforcer's policy format", - "operationId": "listTenantPolicies", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, + }, + "description": "The request conflicts with the resource's current state" + }, + "forbidden": { + "content": { + "application/problem+json": { "schema": { - "$ref": "#/components/schemas/msTenantId" + "$ref": "#/components/schemas/problem" } } - ], - "responses": { - "200": { - "description": "The tenant's policies, in inforcer's policy format", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/policyList" - } - } + }, + "description": "The API client lacks the permission or tenant scope for this request" + }, + "internalServerError": { + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" } - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" - }, - "404": { - "$ref": "#/components/responses/notFound" - }, - "409": { - "$ref": "#/components/responses/conflict" - }, - "429": { - "$ref": "#/components/responses/tooManyRequests" } - } - } - }, - "/v1/tenants/{msTenantId}/alignmentDetails": { - "get": { - "tags": [ - "Alignment details" - ], - "summary": "Get tenant alignment details", - "description": "Compares a tenant's policies with a baseline it is aligned against", - "operationId": "getTenantAlignmentDetails", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, + }, + "description": "An unexpected error occurred" + }, + "notFound": { + "content": { + "application/problem+json": { "schema": { - "$ref": "#/components/schemas/msTenantId" + "$ref": "#/components/schemas/problem" } - }, - { - "name": "baselineId", - "in": "query", - "description": "The baseline's id, as in listBaselines", - "required": true, + } + }, + "description": "The resource does not exist or is outside the API client's tenant scope" + }, + "tooManyRequests": { + "content": { + "application/problem+json": { "schema": { - "type": "string", - "format": "uuid" + "$ref": "#/components/schemas/problem" } } - ], - "responses": { - "200": { - "description": "The tenant's alignment with the baseline", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/alignmentDetails" - } - } + }, + "description": "The rate limit is exceeded", + "headers": { + "Retry-After": { + "description": "Seconds to wait before retrying", + "schema": { + "type": "integer" } - }, - "400": { - "$ref": "#/components/responses/badRequest" - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" - }, - "404": { - "$ref": "#/components/responses/notFound" - }, - "409": { - "$ref": "#/components/responses/conflict" - }, - "429": { - "$ref": "#/components/responses/tooManyRequests" } } - } - }, - "/v1/tenants/{msTenantId}/secureScores": { - "get": { - "tags": [ - "Secure scores" - ], - "summary": "Get tenant secure scores", - "description": "Gets a tenant's Microsoft Secure Score, its history and the controls that would raise it", - "operationId": "getTenantSecureScores", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, + }, + "unauthorized": { + "content": { + "application/problem+json": { "schema": { - "$ref": "#/components/schemas/msTenantId" + "$ref": "#/components/schemas/problem" } } - ], - "responses": { - "200": { - "description": "The tenant's secure scores", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/secureScores" - } - } + }, + "description": "The bearer token is missing, invalid or expired", + "headers": { + "WWW-Authenticate": { + "description": "The Bearer challenge", + "schema": { + "type": "string" } + } + } + } + }, + "schemas": { + "acceptedDeviation": { + "description": "A difference from the baseline that someone accepted or a live scheduled exclusion covers, so it no longer counts as a deviation", + "properties": { + "acceptAllChanges": { + "description": "Whether the deviation accepts every difference rather than listed ones", + "type": "boolean" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "acceptedByUsername": { + "description": "The username of the person who accepted the deviation", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "acceptedTimestamp": { + "description": "When the deviation was accepted", + "format": "date-time", + "type": "string" }, - "404": { - "$ref": "#/components/responses/notFound" + "isObsolete": { + "description": "Whether the policies now align without the deviation", + "type": "boolean" }, - "409": { - "$ref": "#/components/responses/conflict" + "originalBaselineValue": { + "description": "The baseline's value when the deviation was accepted, as JSON", + "nullable": true, + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/tenants/{msTenantId}/users": { - "get": { - "tags": [ - "Users" - ], - "summary": "List tenant users", - "description": "Lists a tenant's Microsoft Entra users by display name, a page at a time", - "operationId": "listTenantUsers", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } + "policyAssignmentsDiff": { + "description": "The accepted differences in the policy's assignments", + "items": { + "$ref": "#/components/schemas/policyDiff" + }, + "type": "array" }, - { - "name": "search", - "in": "query", - "description": "Only users whose name or user principal name matches this term", - "schema": { - "type": "string" - } + "policyDataDiff": { + "description": "The accepted differences in the policy's settings", + "items": { + "$ref": "#/components/schemas/policyDiff" + }, + "type": "array" }, - { - "name": "continuationToken", - "in": "query", - "description": "The token from the previous page, to fetch the next one", - "schema": { - "type": "string" - } + "reason": { + "description": "The reason given for accepting the deviation", + "nullable": true, + "type": "string" + }, + "validUntil": { + "description": "When the acceptance expires, or null when it does not expire", + "format": "date-time", + "nullable": true, + "type": "string" } + }, + "required": [ + "acceptedTimestamp", + "acceptedByUsername", + "reason", + "acceptAllChanges", + "isObsolete", + "validUntil", + "originalBaselineValue", + "policyDataDiff", + "policyAssignmentsDiff" ], - "responses": { - "200": { - "description": "A page of up to 200 of the tenant's users", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/userList" - } - } - } + "type": "object" + }, + "alignmentDetails": { + "description": "How a tenant's policies compare with one baseline", + "properties": { + "alignmentScore": { + "description": "The tenant's alignment score, from 0 to 100", + "format": "double", + "type": "number" }, - "400": { - "$ref": "#/components/responses/badRequest" + "baseline": { + "$ref": "#/components/schemas/alignmentDetailsBaseline" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "baselineDataTimestamp": { + "description": "When the baseline tenant's policies were last read", + "format": "date-time", + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "completedAt": { + "description": "When the comparison ran", + "format": "date-time", + "type": "string" }, - "404": { - "$ref": "#/components/responses/notFound" + "metrics": { + "$ref": "#/components/schemas/alignmentMetrics" }, - "409": { - "$ref": "#/components/responses/conflict" + "policies": { + "$ref": "#/components/schemas/alignmentPolicies" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "tenantDataTimestamp": { + "description": "When the tenant's policies were last read", + "format": "date-time", + "type": "string" } - } - } - }, - "/v1/tenants/{msTenantId}/users/{userId}": { - "get": { - "tags": [ - "Users" + }, + "required": [ + "completedAt", + "baseline", + "baselineDataTimestamp", + "tenantDataTimestamp", + "alignmentScore", + "metrics", + "policies" ], - "summary": "Get tenant user", - "description": "Gets a tenant's Microsoft Entra user, with their groups, roles and devices", - "operationId": "getTenantUser", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } + "type": "object" + }, + "alignmentDetailsBaseline": { + "description": "The baseline that inforcer compared the tenant with", + "properties": { + "id": { + "description": "The baseline's id", + "format": "uuid", + "type": "string" }, - { - "name": "userId", - "in": "path", - "description": "The user's Microsoft Entra object id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - } + "msTenantId": { + "$ref": "#/components/schemas/msTenantId" } + }, + "required": [ + "id", + "msTenantId" ], - "responses": { - "200": { - "description": "The user", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/user" - } - } - } + "type": "object" + }, + "alignmentMetrics": { + "description": "The number of policies in each outcome", + "properties": { + "additionalInTenant": { + "description": "The number of tenant policies the baseline does not have", + "format": "int32", + "type": "integer" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "deviated": { + "description": "The number of policies that differ from the baseline in ways that are not accepted", + "format": "int32", + "type": "integer" }, - "403": { - "$ref": "#/components/responses/forbidden" + "matched": { + "description": "The number of policies that match the baseline without accepted deviations", + "format": "int32", + "type": "integer" }, - "404": { - "$ref": "#/components/responses/notFound" + "matchedWithAcceptedDeviations": { + "description": "The number of policies that match the baseline because of accepted deviations", + "format": "int32", + "type": "integer" }, - "409": { - "$ref": "#/components/responses/conflict" + "missingFromTenant": { + "description": "The number of baseline policies the tenant does not have", + "format": "int32", + "type": "integer" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "totalPolicies": { + "description": "The number of policies compared, which is the sum of the other counts. It leaves out policy types that the score excludes, though those policies still appear in policies", + "format": "int32", + "type": "integer" } - } - } - }, - "/v1/tenants/{msTenantId}/groups": { - "get": { - "tags": [ - "Groups" + }, + "required": [ + "totalPolicies", + "matched", + "matchedWithAcceptedDeviations", + "deviated", + "missingFromTenant", + "additionalInTenant" ], - "summary": "List tenant groups", - "description": "Lists a tenant's Microsoft Entra groups, a page at a time", - "operationId": "listTenantGroups", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } + "type": "object" + }, + "alignmentPolicies": { + "description": "The compared policies, by outcome", + "properties": { + "additionalInTenant": { + "description": "Tenant policies the baseline does not have", + "items": { + "$ref": "#/components/schemas/comparedPolicy" + }, + "type": "array" }, - { - "name": "search", - "in": "query", - "description": "Only groups whose display name matches this term", - "schema": { - "type": "string" - } - }, - { - "name": "continuationToken", - "in": "query", - "description": "The token from the previous page, to fetch the next one", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "A page of up to 20 of the tenant's groups", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/groupList" - } - } - } - }, - "400": { - "$ref": "#/components/responses/badRequest" - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" + "deviated": { + "description": "Baseline policies the tenant has but with differences that are not accepted", + "items": { + "$ref": "#/components/schemas/comparedPolicy" + }, + "type": "array" }, - "404": { - "$ref": "#/components/responses/notFound" + "matched": { + "description": "Baseline policies the tenant matches exactly", + "items": { + "$ref": "#/components/schemas/comparedPolicy" + }, + "type": "array" }, - "409": { - "$ref": "#/components/responses/conflict" + "matchedWithAcceptedDeviations": { + "description": "Baseline policies the tenant matches once accepted deviations are applied", + "items": { + "$ref": "#/components/schemas/comparedPolicy" + }, + "type": "array" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "missingFromTenant": { + "description": "Baseline policies the tenant does not have", + "items": { + "$ref": "#/components/schemas/comparedPolicy" + }, + "type": "array" } - } - } - }, - "/v1/tenants/{msTenantId}/groups/{groupId}": { - "get": { - "tags": [ - "Groups" + }, + "required": [ + "matched", + "matchedWithAcceptedDeviations", + "deviated", + "missingFromTenant", + "additionalInTenant" ], - "summary": "Get tenant group", - "description": "Gets a tenant's Microsoft Entra group", - "operationId": "getTenantGroup", - "parameters": [ + "type": "object" + }, + "alignmentScore": { + "allOf": [ { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } + "properties": { + "msTenantId": { + "$ref": "#/components/schemas/msTenantId" + }, + "tenantName": { + "description": "The tenant's display name", + "type": "string" + } + }, + "required": [ + "msTenantId", + "tenantName" + ], + "type": "object" }, { - "name": "groupId", - "in": "path", - "description": "The group's Microsoft Entra object id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - } + "$ref": "#/components/schemas/alignmentSummary" } ], - "responses": { - "200": { - "description": "The group", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/group" - } - } - } - }, - "401": { - "$ref": "#/components/responses/unauthorized" + "description": "A tenant's alignment against one baseline" + }, + "alignmentScoreList": { + "description": "The alignment of the licensed tenants in the API client's tenant scope against each of their baselines whose baseline tenant is also in that scope", + "properties": { + "alignmentScores": { + "description": "One entry for each tenant and baseline pair, ordered by tenant name and then baseline name", + "items": { + "$ref": "#/components/schemas/alignmentScore" + }, + "type": "array" + } + }, + "required": [ + "alignmentScores" + ], + "type": "object" + }, + "alignmentSummary": { + "description": "The tenant's alignment against one baseline", + "properties": { + "alignedBaselineId": { + "description": "The baseline's id, or null when another client owns the baseline", + "format": "uuid", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "alignedBaselineMsTenantId": { + "anyOf": [ + { + "$ref": "#/components/schemas/msTenantId" + }, + { + "enum": [ + null + ], + "nullable": true, + "type": "string" + } + ], + "description": "The baseline tenant's Microsoft Entra tenant id" }, - "404": { - "$ref": "#/components/responses/notFound" + "alignedBaselineName": { + "description": "The baseline's name", + "nullable": true, + "type": "string" }, - "409": { - "$ref": "#/components/responses/conflict" + "alignedThreshold": { + "description": "The alignment score, from 0 to 100, at or above which the tenant is aligned", + "format": "double", + "nullable": true, + "type": "number" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/tenants/{msTenantId}/groups/{groupId}/members": { - "get": { - "tags": [ - "Groups" - ], - "summary": "List tenant group members", - "description": "Lists a tenant's Microsoft Entra group's direct members, a page at a time", - "operationId": "listTenantGroupMembers", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } + "alignmentScore": { + "description": "The tenant's latest alignment score, from 0 to 100, or null before its first alignment", + "format": "double", + "nullable": true, + "type": "number" }, - { - "name": "groupId", - "in": "path", - "description": "The group's Microsoft Entra object id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - } + "lastAlignmentTimestamp": { + "description": "When inforcer last compared the tenant with the baseline, or null before its first alignment", + "format": "date-time", + "nullable": true, + "type": "string" }, - { - "name": "continuationToken", - "in": "query", - "description": "The token from the previous page, to fetch the next one", - "schema": { - "type": "string" - } + "semiAlignedThreshold": { + "description": "The alignment score, from 0 to 100, at or above which the tenant is semi-aligned", + "format": "double", + "nullable": true, + "type": "number" } + }, + "required": [ + "alignedBaselineId", + "alignedBaselineMsTenantId", + "alignedBaselineName", + "alignmentScore", + "alignedThreshold", + "semiAlignedThreshold", + "lastAlignmentTimestamp" ], - "responses": { - "200": { - "description": "A page of up to 100 of the group's direct members", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/groupMemberList" - } - } - } + "type": "object" + }, + "assessment": { + "description": "A set of checks that inforcer can run against a tenant", + "properties": { + "assessmentType": { + "description": "The assessment's type, such as platform, custom or community", + "nullable": true, + "type": "string" }, - "400": { - "$ref": "#/components/responses/badRequest" + "created": { + "description": "When the assessment was created, or null when that is not known", + "format": "date-time", + "nullable": true, + "type": "string" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "description": { + "description": "What the assessment covers, or null when it has no description", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "id": { + "description": "The assessment's id", + "type": "string" }, - "404": { - "$ref": "#/components/responses/notFound" + "lastUpdated": { + "description": "When the assessment was last updated, or null when that is not known", + "format": "date-time", + "nullable": true, + "type": "string" }, - "409": { - "$ref": "#/components/responses/conflict" + "name": { + "description": "The assessment's name", + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/tenants/{msTenantId}/directoryRoles": { - "get": { - "tags": [ - "Roles" - ], - "summary": "List tenant roles", - "description": "Lists a tenant's Entra directory role definitions", - "operationId": "listTenantRoles", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } + "tags": { + "description": "The assessment's tags, empty when it has none", + "items": { + "type": "string" + }, + "type": "array" } + }, + "required": [ + "id", + "name", + "description", + "tags", + "assessmentType", + "lastUpdated", + "created" ], - "responses": { - "200": { - "description": "The tenant's role definitions", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/tenantRoleList" - } - } - } - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" + "type": "object" + }, + "assessmentCheckFinding": { + "description": "What a check found when it evaluated the tenant", + "properties": { + "compliant": { + "description": "Whether every evaluated object passes the check. False when the check's data could not be read, see status", + "type": "boolean" }, - "404": { - "$ref": "#/components/responses/notFound" + "message": { + "description": "A summary of the finding", + "nullable": true, + "type": "string" }, - "409": { - "$ref": "#/components/responses/conflict" + "scores": { + "description": "The score of each object the check evaluated", + "items": { + "$ref": "#/components/schemas/assessmentCheckScore" + }, + "type": "array" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "status": { + "description": "The check's outcome. insufficientPermissions and error mean it was not assessed. When null, compliant is the outcome", + "enum": [ + "pass", + "fail", + "insufficientPermissions", + "error" + ], + "nullable": true, + "type": "string" } - } - } - }, - "/v1/tenants/{msTenantId}/assessments/{assessmentId}/runs": { - "post": { - "tags": [ - "Assessments" + }, + "required": [ + "compliant", + "status", + "message", + "scores" ], - "summary": "Run tenant assessment", - "description": "Runs an assessment against a tenant and returns the result of each of its checks", - "operationId": "runTenantAssessment", - "parameters": [ - { - "name": "msTenantId", - "in": "path", - "description": "The tenant's Microsoft Entra tenant id", - "required": true, - "schema": { - "$ref": "#/components/schemas/msTenantId" - } - }, - { - "name": "assessmentId", - "in": "path", - "description": "The id of the assessment to run", - "required": true, - "schema": { + "type": "object" + }, + "assessmentCheckFramework": { + "description": "A framework or standard that references a check, with the check's place in it", + "properties": { + "metadata": { + "additionalProperties": { "type": "string" - } + }, + "description": "The framework's fields for the check, such as control and level", + "type": "object" + }, + "name": { + "description": "The framework's name, such as CIS Microsoft 365 Foundations Benchmark v6.0.0", + "type": "string" } + }, + "required": [ + "name", + "metadata" ], - "responses": { - "200": { - "description": "The assessment's results", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/assessmentRun" - } - } - } + "type": "object" + }, + "assessmentCheckResult": { + "description": "The result of one of an assessment's checks for a tenant", + "properties": { + "category": { + "description": "The product area the check applies to, such as Entra or Exchange", + "nullable": true, + "type": "string" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "created": { + "description": "When the check was created", + "format": "date-time", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "description": { + "description": "What the check verifies, or null when it has no description", + "nullable": true, + "type": "string" }, - "404": { - "$ref": "#/components/responses/notFound" + "findings": { + "$ref": "#/components/schemas/assessmentCheckFinding" }, - "409": { - "$ref": "#/components/responses/conflict" + "frameworks": { + "description": "The frameworks that reference the check, such as a CIS Benchmark", + "items": { + "$ref": "#/components/schemas/assessmentCheckFramework" + }, + "type": "array" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "id": { + "description": "The check's id", + "type": "string" }, - "500": { - "$ref": "#/components/responses/internalServerError" + "impact": { + "description": "The operational impact of applying the recommended configuration", + "nullable": true, + "type": "string" }, - "502": { - "$ref": "#/components/responses/badGateway" - } - } - } - }, - "/v1/baselines": { - "get": { - "tags": [ - "Baselines" - ], - "summary": "List baselines", - "description": "Lists the client's baselines whose baseline tenant is in the API client's tenant scope. A baseline another client shares appears as the client's copy, marked by isSharedCopy", - "operationId": "listBaselines", - "parameters": [ - { - "name": "baselineMsTenantId", - "in": "query", - "description": "Only the baselines of this baseline tenant", - "schema": { - "$ref": "#/components/schemas/msTenantId" - } - } - ], - "responses": { - "200": { - "description": "The baselines", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/baselineList" - } - } - } + "importance": { + "description": "The check's severity, such as High or Medium", + "nullable": true, + "type": "string" }, - "400": { - "$ref": "#/components/responses/badRequest" + "key": { + "description": "The check's machine-readable key, such as ensure_mfa_enabled_for_all_users", + "type": "string" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "lastUpdated": { + "description": "When the check was last updated", + "format": "date-time", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "name": { + "description": "The check's name", + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/alignmentScores": { - "get": { - "tags": [ - "Alignment scores" - ], - "summary": "List alignment scores", - "description": "Lists the alignment of each licensed tenant in the API client's tenant scope against each of its baselines", - "operationId": "listAlignmentScores", - "responses": { - "200": { - "description": "The alignment scores", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/alignmentScoreList" - } - } - } + "rationale": { + "description": "Why the check matters, or null when it has no rationale", + "nullable": true, + "type": "string" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "remediation": { + "description": "How to fix a failing result, in markdown", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "subCategory": { + "description": "The check's sub-category within its category, or null when it has none", + "nullable": true, + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "tags": { + "description": "The check's tags, empty when it has none", + "items": { + "type": "string" + }, + "type": "array" + }, + "version": { + "description": "The version of the check the evaluation used", + "format": "int64", + "type": "integer" } - } - } - }, - "/v1/assessments": { - "get": { - "tags": [ - "Assessments" - ], - "summary": "List assessments", - "description": "Lists the assessments available to the API client's client", - "operationId": "listAssessments", - "responses": { - "200": { - "description": "The assessments", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/assessmentList" - } - } - } - }, - "401": { - "$ref": "#/components/responses/unauthorized" + }, + "required": [ + "id", + "key", + "name", + "category", + "subCategory", + "description", + "importance", + "impact", + "rationale", + "remediation", + "findings", + "frameworks", + "tags", + "version", + "created", + "lastUpdated" + ], + "type": "object" + }, + "assessmentCheckScore": { + "description": "How one evaluated policy or setting scored against a check", + "properties": { + "objectId": { + "description": "The id of the evaluated policy or setting", + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "objectName": { + "description": "The display name of the evaluated policy or setting, or null when it has none", + "nullable": true, + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/reports/runs": { - "get": { - "tags": [ - "Reports" - ], - "summary": "List report runs", - "description": "Lists the client's report runs from the last 7 days, newest first, capped at 500.\nRuns started by the API client or its owner user are always listed.\nWith permission to view others' report runs, scheduled runs and runs started by others are also listed, where the API client can run those reports on all of the run's tenants.\n", - "operationId": "listReportRuns", - "responses": { - "200": { - "description": "The report runs", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/reportRunList" - } - } - } + "passes": { + "description": "The conditions of the check that the object meets", + "items": { + "type": "string" + }, + "type": "array" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "score": { + "description": "100 when the object is fully compliant, 0 when it is fully non-compliant", + "format": "double", + "maximum": 100, + "minimum": 0, + "type": "number" }, - "403": { - "$ref": "#/components/responses/forbidden" + "violations": { + "description": "The conditions of the check that the object fails to meet", + "items": { + "type": "string" + }, + "type": "array" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "warnings": { + "description": "Conditions that may need attention but do not fail the check", + "items": { + "type": "string" + }, + "type": "array" } - } + }, + "required": [ + "objectId", + "objectName", + "score", + "passes", + "violations", + "warnings" + ], + "type": "object" }, - "post": { - "tags": [ - "Reports" + "assessmentList": { + "description": "The assessments the client can run, in one response", + "properties": { + "assessments": { + "description": "The assessments, each with the id that a run needs", + "items": { + "$ref": "#/components/schemas/assessment" + }, + "type": "array" + } + }, + "required": [ + "assessments" ], - "summary": "Trigger report run", - "description": "Queues a run of one or more reports for tenants in the caller's tenant scope.\nEach requested report type needs its run permissions on every requested tenant, and every requested tenant must hold the license that report type needs. Otherwise the request fails with 403.\n", - "operationId": "triggerReportRun", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/triggerReportRunRequest" - }, - "example": { - "reports": [ - { - "type": "CopilotAdoption", - "outputFormat": "pdf", - "parameters": { - "report-period": "30" - } - } - ], - "msTenantIds": [ - "2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091" - ] - } - } + "type": "object" + }, + "assessmentRun": { + "description": "The result of running an assessment against a tenant, with a summary and the result of each check", + "properties": { + "assessmentId": { + "description": "The id of the assessment that was run", + "type": "string" }, - "required": true + "name": { + "description": "The name of the assessment that was run", + "nullable": true, + "type": "string" + }, + "results": { + "description": "The result of each of the assessment's checks", + "items": { + "$ref": "#/components/schemas/assessmentCheckResult" + }, + "type": "array" + }, + "summary": { + "$ref": "#/components/schemas/assessmentRunSummary" + } }, - "responses": { - "202": { - "description": "The report run is queued", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/triggerReportRunResponse" - } - } - } + "required": [ + "assessmentId", + "name", + "summary", + "results" + ], + "type": "object" + }, + "assessmentRunSummary": { + "description": "Counts of the run's checks by outcome", + "properties": { + "assessed": { + "description": "The number of checks with an outcome, all but notRun", + "format": "int32", + "type": "integer" }, - "400": { - "$ref": "#/components/responses/badRequest" + "failed": { + "description": "The number of checks that failed", + "format": "int32", + "type": "integer" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "notRun": { + "description": "The number of checks not assessed, through insufficient permissions or an error", + "format": "int32", + "type": "integer" }, - "403": { - "$ref": "#/components/responses/forbidden" + "passed": { + "description": "The number of checks that passed", + "format": "int32", + "type": "integer" }, - "404": { - "$ref": "#/components/responses/notFound" + "score": { + "description": "Passed checks as a percentage of assessed checks, rounded down. Null when no check was assessed", + "format": "int32", + "maximum": 100, + "minimum": 0, + "nullable": true, + "type": "integer" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/reports/runs/{reportRunId}/outputs": { - "get": { - "tags": [ - "Reports" - ], - "summary": "List report run outputs", - "description": "Lists the rendered outputs of a finished report run, for tenants in the caller's tenant scope. A collated output is listed only when the scope covers every tenant the run targeted", - "operationId": "listReportRunOutputs", - "parameters": [ - { - "name": "reportRunId", - "in": "path", - "description": "The report run's id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - } + "total": { + "description": "The number of checks in the run", + "format": "int32", + "type": "integer" } + }, + "required": [ + "total", + "assessed", + "passed", + "failed", + "notRun", + "score" ], - "responses": { - "200": { - "description": "The report run's outputs", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/reportRunOutputList" - } - } - } + "type": "object" + }, + "auditEvent": { + "description": "An event in the client's inforcer activity log", + "properties": { + "code": { + "description": "What happened, within the event type", + "type": "string" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "correlationId": { + "description": "Shared by events that belong to the same operation", + "format": "uuid", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "eventType": { + "description": "The event's type, one of those from GET /v1/auditEvents/types", + "type": "string" }, - "404": { - "$ref": "#/components/responses/notFound" + "id": { + "description": "The event's id", + "format": "uuid", + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/reports/runs/{reportRunId}/outputs/{outputId}": { - "get": { - "tags": [ - "Reports" - ], - "summary": "Download a report run output", - "description": "Downloads the content of one output of a finished report run, for a tenant in the caller's tenant scope. A collated output is served only when the scope covers every tenant the run targeted", - "operationId": "getReportRunOutput", - "parameters": [ - { - "name": "reportRunId", - "in": "path", - "description": "The report run's id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - } - }, - { - "name": "outputId", - "in": "path", - "description": "The output's id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - } - } - ], - "responses": { - "200": { - "description": "The output's content, in its format", - "headers": { - "Content-Disposition": { - "description": "The output's file name", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "type": "string", - "format": "binary" - } - }, - "text/csv": { - "schema": { - "type": "string", - "format": "binary" - } - }, - "text/html": { - "schema": { - "type": "string", - "format": "binary" - } - }, - "application/pdf": { - "schema": { - "type": "string", - "format": "binary" - } - } - } + "metadata": { + "description": "The event's details, which vary by event type", + "type": "object" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "relId": { + "description": "The id of the entity the event relates to", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "relType": { + "description": "The type of the entity the event relates to", + "nullable": true, + "type": "string" }, - "404": { - "$ref": "#/components/responses/notFound" + "timestamp": { + "description": "When inforcer recorded the event, in UTC", + "format": "date-time", + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "user": { + "description": "Who caused the event", + "type": "string" } - } - } - }, - "/v1/reports/types": { - "get": { - "tags": [ - "Reports" + }, + "required": [ + "id", + "correlationId", + "relType", + "relId", + "eventType", + "code", + "user", + "timestamp", + "metadata" ], - "summary": "List report types", - "description": "Lists the report types the API client holds the run permissions for. Running one also needs each target tenant to hold the license that report type needs", - "operationId": "listReportTypes", - "responses": { - "200": { - "description": "The report types", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/reportTypeList" - } - } - } - }, - "401": { - "$ref": "#/components/responses/unauthorized" - }, - "403": { - "$ref": "#/components/responses/forbidden" + "type": "object" + }, + "auditEventList": { + "description": "A page of events from the client's activity log, newest first", + "properties": { + "auditEvents": { + "description": "The events on this page, newest first", + "items": { + "$ref": "#/components/schemas/auditEvent" + }, + "type": "array" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "continuationToken": { + "description": "The token to fetch the next page, or null when this is the last page", + "nullable": true, + "type": "string" } - } - } - }, - "/v1/auditEvents/types": { - "get": { - "tags": [ - "Audit events" + }, + "required": [ + "auditEvents", + "continuationToken" ], - "summary": "List audit event types", - "description": "Lists the types of events the activity log records", - "operationId": "listAuditEventTypes", - "responses": { - "200": { - "description": "The audit event types", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/auditEventTypeList" - } + "type": "object" + }, + "auditEventType": { + "description": "A type of event the activity log records", + "properties": { + "name": { + "description": "The event type's name", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "auditEventTypeList": { + "description": "The types of event the activity log records", + "properties": { + "eventTypes": { + "description": "The event types", + "items": { + "$ref": "#/components/schemas/auditEventType" + }, + "type": "array" + } + }, + "required": [ + "eventTypes" + ], + "type": "object" + }, + "baseline": { + "description": "A set of policies that inforcer compares member tenants against", + "properties": { + "alignedThreshold": { + "description": "The alignment score, from 0 to 100, at or above which a member is aligned", + "format": "double", + "type": "number" + }, + "autoAddNewPolicies": { + "description": "Whether new policies on the baseline tenant join the baseline automatically", + "type": "boolean" + }, + "baselineTenant": { + "allOf": [ + { + "$ref": "#/components/schemas/tenant" } - } + ], + "description": "The tenant the baseline's policies come from. For a shared copy it belongs to the sharing client" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "description": { + "description": "The baseline's description, or null when it has none", + "nullable": true, + "type": "string" }, - "403": { - "$ref": "#/components/responses/forbidden" + "id": { + "description": "The baseline's id", + "format": "uuid", + "type": "string" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" - } - } - } - }, - "/v1/auditEvents/search": { - "post": { - "tags": [ - "Audit events" - ], - "summary": "Search audit events", - "description": "Searches the activity log of the API client's client, newest first", - "operationId": "searchAuditEvents", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/searchAuditEventsRequest" - }, - "example": { - "eventTypes": [ - "authentication", - "failedAuthentication" - ], - "dateFrom": "2026-02-01T00:00:00Z", - "dateTo": "2026-02-26T23:59:59Z", - "pageSize": 50 - } - } + "isComplete": { + "description": "Whether the baseline has finished being set up", + "type": "boolean" }, - "required": true - }, - "responses": { - "200": { - "description": "The matching audit events", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/auditEventList" - } - } - } + "isShared": { + "description": "Whether the client shares the baseline with other clients", + "type": "boolean" }, - "400": { - "$ref": "#/components/responses/badRequest" + "isSharedCopy": { + "description": "Whether the baseline is the client's copy of a baseline another client shares", + "type": "boolean" }, - "401": { - "$ref": "#/components/responses/unauthorized" + "items": { + "description": "The policy categories the baseline includes, or excludes when mode is exclude, including those of the baselines it nests. Individual policies are not listed", + "items": { + "$ref": "#/components/schemas/baselineItem" + }, + "type": "array" }, - "403": { - "$ref": "#/components/responses/forbidden" + "members": { + "description": "The client's own tenants assigned to the baseline, limited to the API client's tenant scope", + "items": { + "$ref": "#/components/schemas/baselineMember" + }, + "type": "array" }, - "429": { - "$ref": "#/components/responses/tooManyRequests" + "mode": { + "description": "Whether members are compared against the baseline's policies, or against all but those", + "enum": [ + "include", + "exclude" + ], + "type": "string" + }, + "name": { + "description": "The baseline's display name", + "type": "string" + }, + "semiAlignedThreshold": { + "description": "The alignment score, from 0 to 100, at or above which a member is semi-aligned", + "format": "double", + "type": "number" } - } - } - } - }, - "components": { - "schemas": { - "msTenantId": { - "type": "string", - "description": "A Microsoft Entra tenant id", - "format": "uuid" + }, + "required": [ + "id", + "name", + "description", + "baselineTenant", + "mode", + "alignedThreshold", + "semiAlignedThreshold", + "autoAddNewPolicies", + "isComplete", + "isShared", + "isSharedCopy", + "members", + "items" + ], + "type": "object" }, - "problem": { - "type": "object", + "baselineItem": { + "description": "A policy category the baseline includes, or excludes when its mode is exclude", "properties": { - "type": { - "type": "string", - "description": "Identifies the problem type", - "format": "uri-reference" - }, - "title": { - "type": "string", - "description": "A short summary of the problem type" + "alignAssignments": { + "description": "Whether the policies' assignments are compared", + "type": "boolean" }, - "status": { - "type": "integer", - "description": "The HTTP status code", - "format": "int32" + "primaryGroup": { + "description": "The policy primary group, or null for the whole product", + "nullable": true, + "type": "string" }, - "detail": { - "type": "string", - "description": "An explanation specific to this occurrence" + "product": { + "description": "The policy product, as in a policy's product", + "type": "string" }, - "instance": { - "type": "string", - "description": "Identifies this occurrence", - "format": "uri-reference" + "secondaryGroup": { + "description": "The policy secondary group, or null for the whole primary group", + "nullable": true, + "type": "string" } }, - "description": "An RFC 9457 problem details object" + "required": [ + "product", + "primaryGroup", + "secondaryGroup", + "alignAssignments" + ], + "type": "object" }, - "validationProblem": { - "allOf": [ - { - "$ref": "#/components/schemas/problem" - }, - { - "type": "object", - "properties": { - "errors": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - }, - "description": "Validation messages keyed by the field they apply to" - } - } + "baselineList": { + "description": "The client's baselines whose baseline tenant is in the API client's tenant scope", + "properties": { + "baselines": { + "description": "The baselines, including the client's copies of baselines other clients share", + "items": { + "$ref": "#/components/schemas/baseline" + }, + "type": "array" } - ] - }, - "tenantList": { + }, "required": [ - "tenants" + "baselines" ], - "type": "object", + "type": "object" + }, + "baselineMember": { + "description": "A tenant assigned to a baseline", "properties": { - "tenants": { - "type": "array", - "items": { - "$ref": "#/components/schemas/tenantListItem" - } + "dnsName": { + "description": "The tenant's primary DNS name", + "type": "string" + }, + "lastAlignmentScore": { + "description": "The member's latest alignment score, from 0 to 100, or null before its first alignment", + "format": "double", + "nullable": true, + "type": "number" + }, + "lastAlignmentTimestamp": { + "description": "When inforcer last compared the member with the baseline, or null before its first alignment", + "format": "date-time", + "nullable": true, + "type": "string" + }, + "msTenantId": { + "$ref": "#/components/schemas/msTenantId" + }, + "name": { + "description": "The tenant's display name", + "type": "string" } - } - }, - "tenantListItem": { + }, "required": [ "msTenantId", "name", "dnsName", - "isBaseline", - "recentChanges", - "tags", - "alignmentSummaries", - "licenses" + "lastAlignmentScore", + "lastAlignmentTimestamp" ], - "type": "object", + "type": "object" + }, + "comparedPolicy": { + "description": "A policy compared between the baseline and the tenant, with its differences, variables, accepted deviations and similar policies", "properties": { - "msTenantId": { - "$ref": "#/components/schemas/msTenantId" + "acceptedDeviations": { + "description": "Deviations accepted for a policy missing from the tenant, newest first", + "items": { + "$ref": "#/components/schemas/acceptedDeviation" + }, + "type": "array" }, - "name": { - "type": "string", - "description": "The tenant's display name" + "description": { + "description": "The description in the policy's own data, or null when it has none", + "nullable": true, + "type": "string" }, - "dnsName": { - "type": "string", - "description": "The tenant's primary DNS name" + "displayName": { + "description": "The baseline policy's name in Microsoft 365, or the tenant policy's name when only the tenant has the policy", + "nullable": true, + "type": "string" }, - "secureScore": { - "type": "number", - "description": "The tenant's latest Microsoft Secure Score, or null when the tenant has not been scored", - "format": "double", - "nullable": true + "friendlyName": { + "description": "inforcer's friendly name for the policy, or its display name when inforcer has none", + "nullable": true, + "type": "string" }, - "isBaseline": { - "type": "boolean", - "description": "Whether the tenant is a baseline" + "id": { + "description": "The policy's id in Microsoft 365: the baseline policy's, or the tenant policy's when only the tenant has it", + "nullable": true, + "type": "string" }, - "lastBackupTimestamp": { - "type": "string", - "description": "When the tenant was last backed up", - "format": "date-time", - "nullable": true + "platform": { + "description": "The platform of the policy's category, such as Android Device Administrator, or null when there is none", + "nullable": true, + "type": "string" }, - "recentChanges": { - "type": "integer", - "description": "The number of policy changes detected recently", - "format": "int32" + "policyTypeFriendlyName": { + "description": "The policy type's display label", + "nullable": true, + "type": "string" }, - "policyDiff": { - "type": "string", - "description": "A summary of the tenant's policy drift", - "nullable": true + "policyTypeId": { + "description": "inforcer's numeric id for the policy type", + "format": "int32", + "type": "integer" + }, + "policyTypeName": { + "description": "inforcer's name for the policy type, or an empty string when the type is not recognised", + "type": "string" + }, + "primaryGroup": { + "description": "The primary group of the policy's category, such as Android or iOS, or null when there is none", + "nullable": true, + "type": "string" + }, + "product": { + "description": "The product the policy's category belongs to", + "nullable": true, + "type": "string" + }, + "readOnly": { + "description": "Whether the policy is read-only because it is Microsoft-managed or created from a template", + "type": "boolean" + }, + "secondaryGroup": { + "description": "The secondary group of the policy's category, such as Configuration Profiles, or null when there is none", + "nullable": true, + "type": "string" + }, + "similarPolicies": { + "description": "Tenant policies that closely match a baseline policy the tenant does not have", + "items": { + "$ref": "#/components/schemas/similarPolicy" + }, + "type": "array" }, "tags": { - "type": "array", + "description": "The baseline policy's tags in inforcer. Empty when only the tenant has the policy", "items": { - "$ref": "#/components/schemas/tenantTag" - } + "$ref": "#/components/schemas/policyTag" + }, + "type": "array" }, - "alignmentSummaries": { - "type": "array", + "tenantPolicies": { + "description": "The tenant's policies that match the baseline policy, with their differences", "items": { - "$ref": "#/components/schemas/alignmentSummary" - } + "$ref": "#/components/schemas/tenantPolicyMatch" + }, + "type": "array" }, - "licenses": { - "type": "array", + "variables": { + "description": "The client variables substituted when comparing the policy", "items": { - "$ref": "#/components/schemas/tenantLicense" - } + "$ref": "#/components/schemas/variableSubstitution" + }, + "type": "array" } - } - }, - "tenant": { + }, "required": [ - "msTenantId", - "name", - "dnsName" + "id", + "policyTypeId", + "policyTypeName", + "policyTypeFriendlyName", + "displayName", + "friendlyName", + "description", + "readOnly", + "product", + "primaryGroup", + "secondaryGroup", + "platform", + "tags", + "tenantPolicies", + "variables", + "acceptedDeviations", + "similarPolicies" ], - "type": "object", + "type": "object" + }, + "group": { + "description": "A Microsoft Entra group of a tenant, read from Microsoft Graph", "properties": { - "msTenantId": { - "$ref": "#/components/schemas/msTenantId" + "createdDateTime": { + "description": "When the group was created in Microsoft Entra, in UTC", + "format": "date-time", + "nullable": true, + "type": "string" }, - "name": { - "type": "string", - "description": "The tenant's display name" + "description": { + "description": "The group's description, or null when it has none", + "nullable": true, + "type": "string" }, - "dnsName": { - "type": "string", - "description": "The tenant's primary DNS name" - } - } - }, - "tenantDetail": { - "required": [ - "msTenantId", - "name", - "dnsName", - "isBaseline", - "recentChanges", - "tags", - "alignmentSummaries", - "licenses" - ], - "type": "object", - "properties": { - "msTenantId": { - "$ref": "#/components/schemas/msTenantId" + "displayName": { + "description": "The group's display name", + "nullable": true, + "type": "string" }, - "name": { - "type": "string", - "description": "The tenant's display name" + "groupTypes": { + "description": "The group's Microsoft Entra group types, such as Unified for a Microsoft 365 group or DynamicMembership for a dynamic group. Empty for a static security group or a distribution list", + "items": { + "type": "string" + }, + "type": "array" }, - "dnsName": { - "type": "string", - "description": "The tenant's primary DNS name" + "id": { + "description": "The group's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" }, - "secureScore": { - "type": "number", - "description": "The tenant's latest Microsoft Secure Score, or null when the tenant has not been scored", - "format": "double", - "nullable": true + "mail": { + "description": "The group's email address, or null when it has none", + "nullable": true, + "type": "string" }, - "isBaseline": { - "type": "boolean", - "description": "Whether the tenant is a baseline" + "mailEnabled": { + "description": "Whether the group is mail-enabled", + "nullable": true, + "type": "boolean" }, - "lastBackupTimestamp": { - "type": "string", - "description": "When the tenant was last backed up", - "format": "date-time", - "nullable": true + "mailNickname": { + "description": "The group's mail alias", + "nullable": true, + "type": "string" }, - "recentChanges": { - "type": "integer", - "description": "The number of policy changes detected recently", - "format": "int32" + "membershipRule": { + "description": "The rule for a dynamic group's members, or null for an assigned group", + "nullable": true, + "type": "string" }, - "policyDiff": { - "type": "string", - "description": "A summary of the tenant's policy drift", - "nullable": true + "onPremisesSyncEnabled": { + "description": "True when the group syncs from an on-premises directory, false when it no longer syncs, or null when it never has", + "nullable": true, + "type": "boolean" }, - "tags": { - "type": "array", - "items": { - "$ref": "#/components/schemas/tenantTag" - } + "visibility": { + "description": "Public, Private or HiddenMembership", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id", + "displayName", + "description", + "mail", + "mailNickname", + "visibility", + "membershipRule", + "groupTypes", + "createdDateTime", + "mailEnabled", + "onPremisesSyncEnabled" + ], + "type": "object" + }, + "groupList": { + "description": "A page of a tenant's Microsoft Entra groups", + "properties": { + "continuationToken": { + "description": "The token to fetch the next page, or null when this is the last page", + "nullable": true, + "type": "string" }, - "alignmentSummaries": { - "type": "array", - "items": { - "$ref": "#/components/schemas/alignmentSummary" - } + "groupCount": { + "description": "The number of groups that match, across every page", + "format": "int64", + "type": "integer" }, - "licenses": { - "type": "array", + "groups": { + "description": "The groups on this page", "items": { - "$ref": "#/components/schemas/tenantLicense" - } - }, - "authenticationMode": { - "enum": [ - "clientSecret", - "workloadIdentityFederation" - ], - "type": "string", - "description": "How inforcer authenticates to the tenant, or null when the mode could not be determined", - "nullable": true + "$ref": "#/components/schemas/groupSummary" + }, + "type": "array" } - } + }, + "required": [ + "groups", + "groupCount", + "continuationToken" + ], + "type": "object" }, - "tenantTag": { + "groupMember": { + "description": "A direct member of a Microsoft Entra group, such as a user or another group", + "properties": { + "displayName": { + "description": "The member's display name", + "nullable": true, + "type": "string" + }, + "id": { + "description": "The member's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" + }, + "type": { + "description": "The member's OData type, such as #microsoft.graph.user", + "nullable": true, + "type": "string" + } + }, "required": [ - "name", - "description" + "id", + "displayName", + "type" ], - "type": "object", + "type": "object" + }, + "groupMemberList": { + "description": "A page of a Microsoft Entra group's direct members", "properties": { - "name": { + "continuationToken": { + "description": "The token to fetch the next page, or null when this is the last page", + "nullable": true, "type": "string" }, - "description": { - "type": "string" + "memberCount": { + "description": "The number of the group's direct members, across every page, or null when Microsoft Graph does not report it for this page", + "format": "int64", + "nullable": true, + "type": "integer" + }, + "members": { + "description": "The direct members on this page. The list does not include members of nested groups", + "items": { + "$ref": "#/components/schemas/groupMember" + }, + "type": "array" } - } - }, - "alignmentSummary": { + }, "required": [ - "alignedBaselineId", - "alignedBaselineMsTenantId", - "alignedBaselineName", - "alignmentScore", - "alignedThreshold", - "semiAlignedThreshold", - "lastAlignmentTimestamp" + "members", + "memberCount", + "continuationToken" ], - "type": "object", + "type": "object" + }, + "groupSummary": { + "description": "A Microsoft Entra group of a tenant, from inforcer's synced copy of the tenant's directory", "properties": { - "alignedBaselineId": { - "type": "string", - "description": "The baseline's id, or null when another client owns the baseline", - "format": "uuid", - "nullable": true + "description": { + "description": "The group's description, or null when it has none", + "nullable": true, + "type": "string" }, - "alignedBaselineMsTenantId": { - "anyOf": [ - { - "$ref": "#/components/schemas/msTenantId" - }, - { - "enum": [ - null - ], - "type": "string", - "nullable": true - } - ], - "description": "The baseline tenant's Microsoft Entra tenant id" + "displayName": { + "description": "The group's display name", + "nullable": true, + "type": "string" }, - "alignedBaselineName": { - "type": "string", - "nullable": true + "groupTypes": { + "description": "The group's Microsoft Entra group types, such as Unified for a Microsoft 365 group or DynamicMembership for a dynamic group. Empty for a static security group or a distribution list", + "items": { + "type": "string" + }, + "type": "array" }, - "alignmentScore": { - "type": "number", - "format": "double", - "nullable": true + "id": { + "description": "The group's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" }, - "alignedThreshold": { - "type": "number", - "format": "double", - "nullable": true + "mail": { + "description": "The group's email address, or null when it has none", + "nullable": true, + "type": "string" }, - "semiAlignedThreshold": { - "type": "number", - "format": "double", - "nullable": true + "membershipRule": { + "description": "The rule for a dynamic group's members, or null for an assigned group", + "nullable": true, + "type": "string" }, - "lastAlignmentTimestamp": { - "type": "string", - "format": "date-time", - "nullable": true + "visibility": { + "description": "Public, Private or HiddenMembership", + "nullable": true, + "type": "string" } }, - "description": "The tenant's alignment against one baseline" - }, - "alignmentScoreList": { "required": [ - "alignmentScores" + "id", + "displayName", + "description", + "mail", + "visibility", + "membershipRule", + "groupTypes" ], - "type": "object", - "properties": { - "alignmentScores": { - "type": "array", - "items": { - "$ref": "#/components/schemas/alignmentScore" - } - } - } + "type": "object" }, - "alignmentScore": { + "msTenantId": { + "description": "A Microsoft Entra tenant id", + "format": "uuid", + "type": "string" + }, + "partialProblem": { "allOf": [ { - "required": [ - "msTenantId", - "tenantName" - ], - "type": "object", - "properties": { - "msTenantId": { - "$ref": "#/components/schemas/msTenantId" - }, - "tenantName": { - "type": "string", - "description": "The tenant's display name" - } - } + "$ref": "#/components/schemas/problem" }, { - "$ref": "#/components/schemas/alignmentSummary" + "properties": { + "results": { + "description": "Each step or item, and whether it was applied", + "items": { + "$ref": "#/components/schemas/stepResult" + }, + "type": "array" + } + }, + "required": [ + "results" + ], + "type": "object" } ], - "description": "A tenant's alignment against one baseline" + "description": "A problem details object for an operation that applied some of its steps or items and failed others" }, - "assessmentList": { - "required": [ - "assessments" - ], - "type": "object", + "policy": { + "description": "A policy of a tenant, in inforcer's policy format", "properties": { - "assessments": { - "type": "array", + "description": { + "description": "The description property of the policy's data, or null when the data has none", + "nullable": true, + "type": "string" + }, + "displayName": { + "description": "The displayName property of the policy's data, or null when the data has none", + "nullable": true, + "type": "string" + }, + "friendlyName": { + "description": "inforcer's friendly name for the policy, or null when inforcer has none", + "nullable": true, + "type": "string" + }, + "id": { + "description": "The policy's id in Microsoft 365", + "type": "string" + }, + "name": { + "description": "The name property of the policy's data, or null when the data has none", + "nullable": true, + "type": "string" + }, + "platform": { + "description": "The platform of the policy's category, such as Android Device Administrator, or null when there is none", + "nullable": true, + "type": "string" + }, + "policyData": { + "description": "The policy as Microsoft 365 returns it", + "type": "object" + }, + "policyTypeId": { + "description": "inforcer's numeric id for the policy type", + "format": "int32", + "type": "integer" + }, + "policyTypeName": { + "description": "inforcer's name for the policy type, or null when the type is not recognised", + "nullable": true, + "type": "string" + }, + "primaryGroup": { + "description": "The primary group of the policy's category, such as Android or iOS, or the policy type's name when the policy has no category", + "type": "string" + }, + "product": { + "description": "The product the policy's category belongs to", + "type": "string" + }, + "readOnly": { + "description": "The readOnly property of the policy's data, or false when the data has none", + "type": "boolean" + }, + "secondaryGroup": { + "description": "The secondary group of the policy's category, such as Configuration Profiles, or null when there is none", + "nullable": true, + "type": "string" + }, + "tags": { + "description": "The client's tags on the policy in inforcer", "items": { - "$ref": "#/components/schemas/assessment" - } + "$ref": "#/components/schemas/policyTag" + }, + "type": "array" } - } - }, - "assessment": { + }, "required": [ "id", + "policyTypeId", + "policyTypeName", "name", + "displayName", + "friendlyName", "description", + "readOnly", + "product", + "primaryGroup", + "secondaryGroup", + "platform", "tags", - "assessmentType", - "lastUpdated", - "created" + "policyData" ], - "type": "object", + "type": "object" + }, + "policyDiff": { + "description": "One difference between the baseline and tenant policies, as a JSON patch operation", "properties": { - "id": { - "type": "string", - "description": "The assessment's id" - }, - "name": { + "baselineValue": { + "description": "The baseline's value, as JSON", + "nullable": true, "type": "string" }, - "description": { - "type": "string", - "nullable": true - }, - "tags": { - "type": "array", - "items": { - "type": "string" - } - }, - "assessmentType": { - "type": "string", - "description": "The assessment's type, such as platform, custom or community", - "nullable": true + "op": { + "description": "The JSON patch operation: add when only the tenant has the value, remove when only the baseline has it, or replace when the values differ", + "type": "string" }, - "lastUpdated": { - "type": "string", - "format": "date-time", - "nullable": true + "path": { + "description": "The JSON path to the value that differs", + "type": "string" }, - "created": { - "type": "string", - "format": "date-time", - "nullable": true + "tenantValue": { + "description": "The tenant's value, as JSON", + "nullable": true, + "type": "string" } - } - }, - "alignmentDetails": { + }, "required": [ - "completedAt", - "baseline", - "baselineDataTimestamp", - "tenantDataTimestamp", - "alignmentScore", - "metrics", - "policies" + "op", + "path", + "baselineValue", + "tenantValue" ], - "type": "object", + "type": "object" + }, + "policyList": { + "description": "A tenant's policies, in inforcer's policy format", "properties": { - "completedAt": { - "type": "string", - "description": "When the comparison ran", - "format": "date-time" - }, - "baseline": { - "$ref": "#/components/schemas/alignmentDetailsBaseline" - }, - "baselineDataTimestamp": { - "type": "string", - "description": "When the baseline tenant's policies were last read", - "format": "date-time" - }, - "tenantDataTimestamp": { - "type": "string", - "description": "When the tenant's policies were last read", - "format": "date-time" - }, - "alignmentScore": { - "type": "number", - "description": "The tenant's alignment score, from 0 to 100", - "format": "double" - }, - "metrics": { - "$ref": "#/components/schemas/alignmentMetrics" + "failedPolicyTypes": { + "additionalProperties": { + "type": "string" + }, + "description": "The policy types that could not be retrieved, by policy type name, with the reason. Their policies are missing from the policies array", + "type": "object" }, "policies": { - "$ref": "#/components/schemas/alignmentPolicies" + "description": "The tenant's policies, grouped by policy type and ordered by display name within each type", + "items": { + "$ref": "#/components/schemas/policy" + }, + "type": "array" } - } - }, - "alignmentDetailsBaseline": { + }, "required": [ - "id", - "msTenantId" + "policies", + "failedPolicyTypes" ], - "type": "object", + "type": "object" + }, + "policyTag": { + "description": "A tag the client puts on policies in inforcer", "properties": { - "id": { - "type": "string", - "description": "The baseline's id", - "format": "uuid" + "description": { + "description": "The tag's description", + "nullable": true, + "type": "string" }, - "msTenantId": { - "$ref": "#/components/schemas/msTenantId" + "name": { + "description": "The tag's text", + "type": "string" } - } - }, - "alignmentMetrics": { + }, "required": [ - "totalPolicies", - "matched", - "matchedWithAcceptedDeviations", - "deviated", - "missingFromTenant", - "additionalInTenant" + "name", + "description" ], - "type": "object", + "type": "object" + }, + "problem": { + "description": "An RFC 9457 problem details object", "properties": { - "totalPolicies": { - "type": "integer", - "format": "int32" + "detail": { + "description": "An explanation specific to this occurrence", + "type": "string" }, - "matched": { - "type": "integer", - "format": "int32" + "instance": { + "description": "Identifies this occurrence", + "format": "uri-reference", + "type": "string" }, - "matchedWithAcceptedDeviations": { - "type": "integer", - "format": "int32" + "status": { + "description": "The HTTP status code", + "format": "int32", + "type": "integer" }, - "deviated": { - "type": "integer", - "format": "int32" + "title": { + "description": "A short summary of the problem type", + "type": "string" }, - "missingFromTenant": { - "type": "integer", - "format": "int32" + "type": { + "description": "Identifies the problem type", + "format": "uri-reference", + "type": "string" + } + }, + "type": "object" + }, + "reportParameter": { + "description": "A parameter that a report type needs to run", + "properties": { + "description": { + "description": "What the parameter sets, such as Report Period", + "type": "string" }, - "additionalInTenant": { - "type": "integer", - "format": "int32" + "key": { + "description": "The parameter's key, to use in a report run's parameters", + "type": "string" + }, + "options": { + "description": "The values the parameter accepts, or null when it accepts any value", + "items": { + "$ref": "#/components/schemas/reportParameterOption" + }, + "nullable": true, + "type": "array" } }, - "description": "The number of policies in each outcome" + "required": [ + "key", + "description", + "options" + ], + "type": "object" }, - "alignmentPolicies": { + "reportParameterOption": { + "description": "A value that a report parameter accepts", + "properties": { + "description": { + "description": "What the value means, such as Last 30 days", + "type": "string" + }, + "key": { + "description": "The value to send for the parameter, such as 30", + "type": "string" + } + }, "required": [ - "matched", - "matchedWithAcceptedDeviations", - "deviated", - "missingFromTenant", - "additionalInTenant" + "key", + "description" ], - "type": "object", + "type": "object" + }, + "reportRun": { + "description": "A run of one or more reports for one or more tenants", "properties": { - "matched": { - "type": "array", - "items": { - "$ref": "#/components/schemas/comparedPolicy" - }, - "description": "Baseline policies the tenant matches exactly" + "completedAt": { + "description": "Null until the run reaches a terminal status", + "format": "date-time", + "nullable": true, + "type": "string" }, - "matchedWithAcceptedDeviations": { - "type": "array", - "items": { - "$ref": "#/components/schemas/comparedPolicy" - }, - "description": "Baseline policies the tenant matches once accepted deviations are applied" + "createdAt": { + "description": "When the run was created, in UTC", + "format": "date-time", + "type": "string" }, - "deviated": { - "type": "array", + "outputCount": { + "description": "The number of successful outputs. Null while running, or for a failed run with no outputs.", + "minimum": 0, + "nullable": true, + "type": "integer" + }, + "outputFormats": { + "description": "The output formats the run produces. New formats may be added.", "items": { - "$ref": "#/components/schemas/comparedPolicy" + "type": "string" }, - "description": "Baseline policies the tenant has but with differences that are not accepted" + "type": "array" }, - "missingFromTenant": { - "type": "array", + "reportRunId": { + "description": "The report run's id", + "format": "uuid", + "type": "string" + }, + "reportTypes": { + "description": "The keys of the report types the run covers", "items": { - "$ref": "#/components/schemas/comparedPolicy" + "type": "string" }, - "description": "Baseline policies the tenant does not have" + "type": "array" }, - "additionalInTenant": { - "type": "array", + "startedAt": { + "description": "Null until rendering starts", + "format": "date-time", + "nullable": true, + "type": "string" + }, + "status": { + "description": "The run's status. completedWithErrors means at least one report failed to render, and failed means the run stopped with an error", + "enum": [ + "pending", + "running", + "completed", + "completedWithErrors", + "failed" + ], + "type": "string" + }, + "triggeredByType": { + "description": "Who started the run. user is a user or API client, and scheduled is a report schedule", + "enum": [ + "user", + "scheduled" + ], + "type": "string" + } + }, + "required": [ + "reportRunId", + "status", + "reportTypes", + "outputFormats", + "triggeredByType", + "createdAt", + "startedAt", + "completedAt", + "outputCount" + ], + "type": "object" + }, + "reportRunList": { + "description": "The client's report runs from the last 7 days that the API client can see", + "properties": { + "reportRuns": { + "description": "The report runs, newest first", "items": { - "$ref": "#/components/schemas/comparedPolicy" + "$ref": "#/components/schemas/reportRun" }, - "description": "Tenant policies the baseline does not have" + "type": "array" } }, - "description": "The compared policies, by outcome" - }, - "comparedPolicy": { "required": [ - "id", - "policyTypeId", - "policyTypeName", - "policyTypeFriendlyName", - "displayName", - "friendlyName", - "description", - "readOnly", - "product", - "primaryGroup", - "secondaryGroup", - "platform", - "tags", - "tenantPolicies", - "variables", - "acceptedDeviations", - "similarPolicies" + "reportRuns" ], - "type": "object", + "type": "object" + }, + "reportRunOutput": { + "description": "One rendered output of a report run, for one tenant or collated across tenants", "properties": { - "id": { - "type": "string", - "description": "The policy's id in Microsoft 365: the baseline policy's, or the tenant policy's when only the tenant has it", - "nullable": true - }, - "policyTypeId": { - "type": "integer", - "format": "int32" - }, - "policyTypeName": { - "type": "string", - "description": "inforcer's name for the policy type, or an empty string when the type is not recognised" - }, - "policyTypeFriendlyName": { - "type": "string", - "description": "The policy type's display label", - "nullable": true - }, - "displayName": { - "type": "string", - "nullable": true - }, - "friendlyName": { - "type": "string", - "nullable": true + "format": { + "description": "The output format, such as csv, json, html or pdf", + "type": "string" }, - "description": { - "type": "string", - "nullable": true + "id": { + "description": "The output's id", + "format": "uuid", + "type": "string" }, - "readOnly": { - "type": "boolean" + "msTenantId": { + "anyOf": [ + { + "$ref": "#/components/schemas/msTenantId" + }, + { + "enum": [ + null + ], + "nullable": true, + "type": "string" + } + ], + "description": "The tenant the output covers, or null for an output collated across tenants" }, - "product": { - "type": "string", - "description": "The product the policy's category belongs to", - "nullable": true + "reportType": { + "description": "The report type's key", + "type": "string" }, - "primaryGroup": { - "type": "string", - "nullable": true + "sizeBytes": { + "description": "The output's size in bytes, or null when it was not recorded", + "format": "int64", + "nullable": true, + "type": "integer" + } + }, + "required": [ + "id", + "reportType", + "msTenantId", + "format", + "sizeBytes" + ], + "type": "object" + }, + "reportRunOutputList": { + "description": "The rendered outputs of a report run", + "properties": { + "outputs": { + "description": "The run's outputs for tenants where the API client can run that report type and the tenant holds its licence. A collated output appears only when those tenants include every tenant the run targeted", + "items": { + "$ref": "#/components/schemas/reportRunOutput" + }, + "type": "array" + } + }, + "required": [ + "outputs" + ], + "type": "object" + }, + "reportType": { + "description": "A kind of report that inforcer can run for tenants", + "properties": { + "collatable": { + "description": "Whether a run can collate its tenants into one output", + "type": "boolean" }, - "secondaryGroup": { - "type": "string", - "nullable": true + "description": { + "description": "What the report contains", + "nullable": true, + "type": "string" }, - "platform": { - "type": "string", - "nullable": true + "key": { + "description": "The report type's key", + "type": "string" }, - "tags": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyTag" - } + "name": { + "description": "The report type's display name", + "type": "string" }, - "tenantPolicies": { - "type": "array", + "requiredParameters": { + "description": "The parameters a run of this report type needs, or empty when it needs none", "items": { - "$ref": "#/components/schemas/tenantPolicyMatch" + "$ref": "#/components/schemas/reportParameter" }, - "description": "The tenant's policies that match the baseline policy, with their differences" + "type": "array" }, - "variables": { - "type": "array", - "items": { - "$ref": "#/components/schemas/variableSubstitution" - }, - "description": "The client variables substituted when comparing the policy" + "singleTenantOnly": { + "description": "Whether a run can include only one tenant", + "type": "boolean" }, - "acceptedDeviations": { - "type": "array", + "supportedOutputFormats": { + "description": "The output formats a run can produce, such as csv, html, pdf, xlsx or json", "items": { - "$ref": "#/components/schemas/acceptedDeviation" + "type": "string" }, - "description": "Deviations accepted for a policy missing from the tenant, newest first" + "type": "array" }, - "similarPolicies": { - "type": "array", + "tags": { + "description": "Categories for the report type, such as Security, Licensing or Identity", "items": { - "$ref": "#/components/schemas/similarPolicy" + "type": "string" }, - "description": "Tenant policies that closely match a baseline policy the tenant does not have" + "type": "array" } - } - }, - "tenantPolicyMatch": { + }, "required": [ - "id", - "policyDataDiff", - "policyAssignmentsDiff", + "key", + "name", + "description", + "collatable", + "singleTenantOnly", + "supportedOutputFormats", "tags", - "acceptedDeviations" + "requiredParameters" ], - "type": "object", + "type": "object" + }, + "reportTypeList": { + "description": "The report types the API client can run", "properties": { - "id": { - "type": "string", - "description": "The tenant policy's id in Microsoft 365", - "nullable": true - }, - "policyDataDiff": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyDiff" - } - }, - "policyAssignmentsDiff": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyDiff" - } - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyTag" - } - }, - "acceptedDeviations": { - "type": "array", + "reportTypes": { + "description": "The report types, ordered by name", "items": { - "$ref": "#/components/schemas/acceptedDeviation" + "$ref": "#/components/schemas/reportType" }, - "description": "Deviations accepted for this tenant policy, newest first" + "type": "array" } - } - }, - "policyDiff": { + }, "required": [ - "op", - "path", - "baselineValue", - "tenantValue" + "reportTypes" ], - "type": "object", + "type": "object" + }, + "searchAuditEventsRequest": { + "description": "Filters and paging for a search of the client's activity log. Every filter is optional", "properties": { - "op": { + "continuationToken": { + "description": "The token from the previous page, to fetch the next one", + "nullable": true, "type": "string" }, - "path": { + "dateFrom": { + "description": "Only events at or after this time, in whole seconds", + "format": "date-time", + "nullable": true, "type": "string" }, - "baselineValue": { - "type": "string", - "description": "The baseline's value, as JSON", - "nullable": true + "dateTo": { + "description": "Only events at or before the end of this second, in whole seconds", + "format": "date-time", + "nullable": true, + "type": "string" }, - "tenantValue": { - "type": "string", - "description": "The tenant's value, as JSON", - "nullable": true + "eventTypes": { + "description": "Only events of these types", + "items": { + "type": "string" + }, + "nullable": true, + "type": "array" + }, + "pageSize": { + "default": 25, + "description": "The most events to return in one page", + "format": "int32", + "maximum": 100, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "user": { + "description": "Only events by this user", + "nullable": true, + "type": "string" } }, - "description": "One difference between the baseline and tenant policies, as a JSON patch operation" + "type": "object" }, - "variableSubstitution": { - "required": [ - "name", - "description", - "propertyPath", - "baselineValue", - "tenantValue", - "isHidden", - "isBaselineOnly" - ], - "type": "object", + "secureScoreControlCategory": { + "description": "The Microsoft Secure Score of one control category, with its daily history", "properties": { - "name": { + "controlCategory": { + "description": "The control category, such as Identity or Data", "type": "string" }, - "description": { - "type": "string", - "nullable": true - }, - "propertyPath": { - "type": "string", - "description": "The JSON path the variable is substituted at", - "nullable": true - }, - "baselineValue": { - "type": "string", - "nullable": true + "currentScore": { + "description": "What the category's controls add to the latest score", + "format": "double", + "type": "number" }, - "tenantValue": { - "type": "string", - "nullable": true + "currentScorePercentage": { + "description": "The category's latest score as a percentage of its maximum, or 0 when the maximum is 0", + "format": "double", + "type": "number" }, - "isHidden": { - "type": "boolean", - "description": "Whether the variable is hidden, in which case its values are not returned" + "historicScores": { + "description": "The category's daily scores, latest first", + "items": { + "$ref": "#/components/schemas/secureScoreControlCategorySnapshot" + }, + "type": "array" }, - "isBaselineOnly": { - "type": "boolean", - "description": "Whether the variable was found only in the baseline policy" + "maxScore": { + "description": "The most the category's controls can add to the score", + "format": "double", + "type": "number" } - } - }, - "acceptedDeviation": { + }, "required": [ - "acceptedTimestamp", - "acceptedByUsername", - "reason", - "acceptAllChanges", - "isObsolete", - "validUntil", - "originalBaselineValue", - "policyDataDiff", - "policyAssignmentsDiff" + "controlCategory", + "maxScore", + "currentScore", + "currentScorePercentage", + "historicScores" ], - "type": "object", + "type": "object" + }, + "secureScoreControlCategorySnapshot": { + "description": "A control category's Microsoft Secure Score on one day", "properties": { - "acceptedTimestamp": { - "type": "string", - "format": "date-time" - }, - "acceptedByUsername": { - "type": "string", - "nullable": true - }, - "reason": { - "type": "string", - "nullable": true - }, - "acceptAllChanges": { - "type": "boolean", - "description": "Whether the deviation accepts every difference rather than listed ones" - }, - "isObsolete": { - "type": "boolean", - "description": "Whether the policies now align without the deviation" - }, - "validUntil": { - "type": "string", + "createdDateTime": { + "description": "When Microsoft calculated the tenant's score for that day, or null when Microsoft gave no time", "format": "date-time", - "nullable": true + "nullable": true, + "type": "string" }, - "originalBaselineValue": { - "type": "string", - "description": "The baseline's value when the deviation was accepted, as JSON", - "nullable": true + "currentScore": { + "description": "What the category's controls added to the score on that day", + "format": "double", + "type": "number" }, - "policyDataDiff": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyDiff" - } + "currentScorePercentage": { + "description": "The category's score on that day as a percentage of its maximum, or 0 when the maximum is 0", + "format": "double", + "type": "number" }, - "policyAssignmentsDiff": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyDiff" - } + "maxScore": { + "description": "The most the category's current controls can add to the score", + "format": "double", + "type": "number" } - } - }, - "similarPolicy": { + }, "required": [ - "id", - "name", - "policyTypeId", - "policyTypeName", - "policyTypeFriendlyName", - "categoryName", - "similarityScore", - "similarityReason", - "matchPercentage", - "diffCount", - "matchCount", - "policyDataDiff", - "policyAssignmentsDiff", - "lastModified" + "maxScore", + "currentScore", + "currentScorePercentage", + "createdDateTime" ], - "type": "object", + "type": "object" + }, + "secureScoreControlProfile": { + "description": "A Microsoft Secure Score control that the tenant has not fully implemented in its latest score", "properties": { - "id": { - "type": "string", - "description": "The tenant policy's id in Microsoft 365", - "nullable": true - }, - "name": { - "type": "string", - "nullable": true + "actionUrl": { + "description": "Where to implement the control", + "nullable": true, + "type": "string" }, - "policyTypeId": { - "type": "integer", - "format": "int32" + "controlCategory": { + "description": "The category the control belongs to, such as Identity", + "nullable": true, + "type": "string" }, - "policyTypeName": { - "type": "string", - "description": "inforcer's name for the policy type, or an empty string when the type is not recognised", - "nullable": true + "currentScore": { + "description": "What the control adds to the latest score", + "format": "double", + "type": "number" }, - "policyTypeFriendlyName": { - "type": "string", - "description": "The policy type's display label", - "nullable": true + "currentScorePercentage": { + "description": "What the control adds to the latest score, as a percentage of the maximum score", + "format": "double", + "type": "number" }, - "categoryName": { - "type": "string", - "nullable": true + "id": { + "description": "Microsoft's id for the control", + "type": "string" }, - "similarityScore": { - "type": "number", + "maxScore": { + "description": "The most the control can add to the score", "format": "double", - "nullable": true + "type": "number" }, - "similarityReason": { - "anyOf": [ - { - "$ref": "#/components/schemas/similarityReason" - }, - { - "enum": [ - null - ], - "type": "object", - "nullable": true - } - ] + "maxScorePercentage": { + "description": "The most the control can add, as a percentage of the maximum score", + "format": "double", + "type": "number" }, - "matchPercentage": { - "type": "number", - "format": "double" + "remediation": { + "description": "How to implement the control", + "nullable": true, + "type": "string" }, - "diffCount": { - "type": "integer", - "format": "int32" + "remediationImpact": { + "description": "The effect implementing the control has on users", + "nullable": true, + "type": "string" }, - "matchCount": { - "type": "integer", - "format": "int32" + "scoreDifference": { + "description": "The score still available from the control", + "format": "double", + "type": "number" }, - "policyDataDiff": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyDiff" - } + "scoreDifferencePercentage": { + "description": "The score still available from the control, as a percentage of the maximum score", + "format": "double", + "type": "number" }, - "policyAssignmentsDiff": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policyDiff" - } + "service": { + "description": "The Microsoft service the control applies to", + "nullable": true, + "type": "string" }, - "lastModified": { - "type": "string", - "format": "date-time", - "nullable": true + "title": { + "description": "The control's title, as Microsoft names it", + "nullable": true, + "type": "string" } - } - }, - "similarityReason": { + }, "required": [ - "summary", - "critical", - "configuration", - "assignments", - "metadata" + "id", + "title", + "controlCategory", + "service", + "remediation", + "remediationImpact", + "actionUrl", + "maxScore", + "maxScorePercentage", + "currentScore", + "currentScorePercentage", + "scoreDifference", + "scoreDifferencePercentage" ], - "type": "object", + "type": "object" + }, + "secureScoreSnapshot": { + "description": "A tenant's Microsoft Secure Score on one day", "properties": { - "summary": { - "type": "string", - "nullable": true - }, - "critical": { - "type": "number", - "format": "double", - "nullable": true + "createdDateTime": { + "description": "When Microsoft calculated the score, or null when Microsoft did not say", + "format": "date-time", + "nullable": true, + "type": "string" }, - "configuration": { - "type": "number", + "currentScore": { + "description": "The score on that day, or 0 when Microsoft did not report one", "format": "double", - "nullable": true + "type": "number" }, - "assignments": { - "type": "number", + "currentScorePercentage": { + "description": "The score as a percentage of the maximum, or 0 when the maximum is 0", "format": "double", - "nullable": true + "type": "number" }, - "metadata": { - "type": "number", + "maxScore": { + "description": "The highest score the tenant could reach on that day, or 0 when Microsoft did not report one", "format": "double", - "nullable": true + "type": "number" } }, - "description": "How the similarity score breaks down" - }, - "baselineList": { "required": [ - "baselines" + "currentScore", + "maxScore", + "currentScorePercentage", + "createdDateTime" ], - "type": "object", - "properties": { - "baselines": { - "type": "array", - "items": { - "$ref": "#/components/schemas/baseline" - } - } - } + "type": "object" }, - "baseline": { - "required": [ - "id", - "name", - "description", - "baselineTenant", - "mode", - "alignedThreshold", - "semiAlignedThreshold", - "autoAddNewPolicies", - "isComplete", - "isShared", - "isSharedCopy", - "members", - "items" - ], - "type": "object", + "secureScores": { + "description": "A tenant's Microsoft Secure Score from Microsoft Graph, with its daily history, the controls that would raise it and the scores per control category", "properties": { - "id": { - "type": "string", - "format": "uuid" + "controlCategoryScores": { + "description": "The scores per control category", + "items": { + "$ref": "#/components/schemas/secureScoreControlCategory" + }, + "type": "array" }, - "name": { - "type": "string", - "description": "The baseline's display name" + "controlProfiles": { + "description": "The controls that would raise the latest score, most impactful first", + "items": { + "$ref": "#/components/schemas/secureScoreControlProfile" + }, + "type": "array" }, - "description": { - "type": "string", - "nullable": true + "currentScore": { + "description": "The latest score, or null when the tenant has not been scored", + "format": "double", + "nullable": true, + "type": "number" }, - "baselineTenant": { - "allOf": [ - { - "$ref": "#/components/schemas/tenant" - } - ], - "description": "The tenant the baseline's policies come from. For a shared copy it belongs to the sharing client" + "currentScorePercentage": { + "description": "The latest score as a percentage of the maximum", + "format": "double", + "nullable": true, + "type": "number" }, - "mode": { - "enum": [ - "include", - "exclude" - ], - "type": "string", - "description": "Whether members are compared against the baseline's policies, or against all but those" + "enabledServices": { + "description": "The Microsoft services the latest score covers", + "items": { + "type": "string" + }, + "type": "array" }, - "alignedThreshold": { - "type": "number", - "description": "The alignment score, from 0 to 100, at or above which a member is aligned", - "format": "double" + "licensedUserCount": { + "description": "The number of licensed users the latest score covers", + "format": "int32", + "nullable": true, + "type": "integer" }, - "semiAlignedThreshold": { - "type": "number", - "description": "The alignment score, from 0 to 100, at or above which a member is semi-aligned", - "format": "double" + "maxScore": { + "description": "The highest score the tenant could reach", + "format": "double", + "nullable": true, + "type": "number" }, - "autoAddNewPolicies": { - "type": "boolean", - "description": "Whether new policies on the baseline tenant join the baseline automatically" + "scores": { + "description": "The tenant's daily scores, latest first", + "items": { + "$ref": "#/components/schemas/secureScoreSnapshot" + }, + "type": "array" + } + }, + "required": [ + "currentScore", + "maxScore", + "currentScorePercentage", + "licensedUserCount", + "enabledServices", + "scores", + "controlProfiles", + "controlCategoryScores" + ], + "type": "object" + }, + "similarPolicy": { + "description": "A tenant policy of the same type that closely matches a baseline policy the tenant does not have", + "properties": { + "categoryName": { + "description": "The baseline policy's category, as its product and primary group joined by a hyphen, or null when the policy has no category", + "nullable": true, + "type": "string" }, - "isComplete": { - "type": "boolean", - "description": "Whether the baseline has finished being set up" + "diffCount": { + "description": "The number of differences between the two policies' settings", + "format": "int32", + "type": "integer" }, - "isShared": { - "type": "boolean", - "description": "Whether the client shares the baseline with other clients" + "id": { + "description": "The tenant policy's id in Microsoft 365", + "nullable": true, + "type": "string" }, - "isSharedCopy": { - "type": "boolean", - "description": "Whether the baseline is the client's copy of a baseline another client shares" + "lastModified": { + "description": "The time of the tenant policy's latest snapshot in inforcer, in UTC", + "format": "date-time", + "nullable": true, + "type": "string" }, - "members": { - "type": "array", + "matchCount": { + "description": "The number of top-level properties across both policies less diffCount, which estimates how many properties match", + "format": "int32", + "type": "integer" + }, + "matchPercentage": { + "description": "The similarity score as a percentage, from 0 to 100", + "format": "double", + "type": "number" + }, + "name": { + "description": "The tenant policy's name", + "nullable": true, + "type": "string" + }, + "policyAssignmentsDiff": { + "description": "The differences between the baseline and tenant policies' assignments", "items": { - "$ref": "#/components/schemas/baselineMember" + "$ref": "#/components/schemas/policyDiff" }, - "description": "The client's own tenants assigned to the baseline, limited to the API client's tenant scope" + "type": "array" }, - "items": { - "type": "array", + "policyDataDiff": { + "description": "The differences between the baseline and tenant policies' settings", "items": { - "$ref": "#/components/schemas/baselineItem" + "$ref": "#/components/schemas/policyDiff" }, - "description": "The policy categories the baseline includes, or excludes when mode is exclude, including those of the baselines it nests. Individual policies are not listed" - } - } - }, - "baselineMember": { - "required": [ - "msTenantId", - "name", - "dnsName", - "lastAlignmentScore", - "lastAlignmentTimestamp" - ], - "type": "object", - "properties": { - "msTenantId": { - "$ref": "#/components/schemas/msTenantId" + "type": "array" }, - "name": { - "type": "string", - "description": "The tenant's display name" + "policyTypeFriendlyName": { + "description": "The policy type's display label", + "nullable": true, + "type": "string" }, - "dnsName": { - "type": "string", - "description": "The tenant's primary DNS name" + "policyTypeId": { + "description": "inforcer's numeric id for the policy type", + "format": "int32", + "type": "integer" }, - "lastAlignmentScore": { - "type": "number", - "description": "The member's latest alignment score, from 0 to 100, or null before its first alignment", - "format": "double", - "nullable": true + "policyTypeName": { + "description": "inforcer's name for the policy type, or an empty string when the type is not recognised", + "nullable": true, + "type": "string" }, - "lastAlignmentTimestamp": { - "type": "string", - "format": "date-time", - "nullable": true + "similarityReason": { + "anyOf": [ + { + "$ref": "#/components/schemas/similarityReason" + }, + { + "enum": [ + null + ], + "nullable": true, + "type": "object" + } + ], + "description": "How the similarity score breaks down" + }, + "similarityScore": { + "description": "How similar the two policies are, from 0 to 1", + "format": "double", + "nullable": true, + "type": "number" } - } - }, - "baselineItem": { + }, "required": [ - "product", - "primaryGroup", - "secondaryGroup", - "alignAssignments" + "id", + "name", + "policyTypeId", + "policyTypeName", + "policyTypeFriendlyName", + "categoryName", + "similarityScore", + "similarityReason", + "matchPercentage", + "diffCount", + "matchCount", + "policyDataDiff", + "policyAssignmentsDiff", + "lastModified" ], - "type": "object", + "type": "object" + }, + "similarityReason": { + "description": "How the similarity score breaks down", "properties": { - "product": { - "type": "string", - "description": "The policy product, as in a policy's product" + "assignments": { + "description": "The similarity of the policies' assignments, as a percentage from 0 to 100, or 100 when neither policy has assignments to compare", + "format": "double", + "nullable": true, + "type": "number" }, - "primaryGroup": { - "type": "string", - "description": "The policy primary group, or null for the whole product", - "nullable": true + "configuration": { + "description": "The similarity of the policies' settings, as a percentage from 0 to 100, or 100 when neither policy has settings to compare", + "format": "double", + "nullable": true, + "type": "number" }, - "secondaryGroup": { - "type": "string", - "description": "The policy secondary group, or null for the whole primary group", - "nullable": true + "critical": { + "description": "The similarity of critical settings, as a percentage. Always 100, because inforcer does not score critical settings separately", + "format": "double", + "nullable": true, + "type": "number" }, - "alignAssignments": { - "type": "boolean", - "description": "Whether the policies' assignments are compared" - } - } - }, - "tenantLicense": { - "required": [ - "sku" - ], - "type": "object", - "properties": { - "sku": { - "type": "string", - "description": "The license SKU" + "metadata": { + "description": "The similarity of the policies' metadata, as a percentage. Always 100, because inforcer does not score metadata", + "format": "double", + "nullable": true, + "type": "number" + }, + "summary": { + "description": "A label for the overall similarity: Nearly identical policies, Highly similar policies, Moderately similar policies or Low similarity", + "nullable": true, + "type": "string" } - } - }, - "tenantRoleList": { + }, "required": [ - "roles" + "summary", + "critical", + "configuration", + "assignments", + "metadata" ], - "type": "object", - "properties": { - "roles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/tenantRole" - } - } - } + "type": "object" }, - "tenantRole": { - "required": [ - "id", - "templateId", - "displayName", - "description", - "isBuiltIn", - "isEnabled", - "isPrivileged" - ], - "type": "object", + "stepResult": { + "description": "The outcome of one step or item of an operation that partly succeeded", "properties": { "id": { - "type": "string", - "description": "The role definition's id" - }, - "templateId": { - "type": "string", - "description": "The id of the role template the definition is based on", - "nullable": true - }, - "displayName": { - "type": "string", - "description": "The role's display name" + "description": "The item's id, when the step acts on one of several items. Usually a uuid, but not for every item, such as a passkey", + "type": "string" }, - "description": { - "type": "string", - "description": "The role's description", - "nullable": true + "status": { + "description": "Whether the step was applied", + "enum": [ + "succeeded", + "failed" + ], + "type": "string" }, - "isBuiltIn": { - "type": "boolean", - "description": "Whether Microsoft defines the role" + "statusCode": { + "description": "The HTTP status the step failed with", + "format": "int32", + "type": "integer" }, - "isEnabled": { - "type": "boolean", - "description": "Whether the role is enabled" + "step": { + "description": "The step or item, such as `profile`, `manager` or an authentication method's type", + "type": "string" }, - "isPrivileged": { - "type": "boolean", - "description": "Whether Microsoft classes the role as privileged" + "title": { + "description": "Why the step failed", + "type": "string" } - } - }, - "policyList": { + }, "required": [ - "policies", - "failedPolicyTypes" + "step", + "status" ], - "type": "object", + "type": "object" + }, + "tenant": { + "description": "A tenant's Microsoft Entra tenant id, display name, and primary DNS name", "properties": { - "policies": { - "type": "array", - "items": { - "$ref": "#/components/schemas/policy" - } + "dnsName": { + "description": "The tenant's primary DNS name", + "type": "string" }, - "failedPolicyTypes": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "The policy types that could not be retrieved, by policy type name, with the reason. Their policies are missing from the policies array" + "msTenantId": { + "$ref": "#/components/schemas/msTenantId" + }, + "name": { + "description": "The tenant's display name", + "type": "string" } - } - }, - "policy": { + }, "required": [ - "id", - "policyTypeId", - "policyTypeName", + "msTenantId", "name", - "displayName", - "friendlyName", - "description", - "readOnly", - "product", - "primaryGroup", - "secondaryGroup", - "platform", - "tags", - "policyData" + "dnsName" ], - "type": "object", + "type": "object" + }, + "tenantDetail": { + "description": "A tenant in the API client's tenant scope, with its Secure Score, backup state, tags, alignment, licences, and authentication mode", "properties": { - "id": { - "type": "string", - "description": "The policy's id in Microsoft 365" - }, - "policyTypeId": { - "type": "integer", - "format": "int32" + "alignmentSummaries": { + "description": "The tenant's alignment against each baseline it is a member of, empty when it is in no baseline", + "items": { + "$ref": "#/components/schemas/alignmentSummary" + }, + "type": "array" }, - "policyTypeName": { - "type": "string", - "description": "inforcer's name for the policy type, or null when the type is not recognised", - "nullable": true + "authenticationMode": { + "description": "How inforcer authenticates to the tenant, or null when the mode could not be determined", + "enum": [ + "clientSecret", + "workloadIdentityFederation" + ], + "nullable": true, + "type": "string" }, - "name": { - "type": "string", - "nullable": true + "dnsName": { + "description": "The tenant's primary DNS name", + "type": "string" }, - "displayName": { - "type": "string", - "nullable": true + "isBaseline": { + "description": "Whether the tenant is a baseline", + "type": "boolean" }, - "friendlyName": { - "type": "string", - "nullable": true + "lastBackupTimestamp": { + "description": "When the tenant was last backed up", + "format": "date-time", + "nullable": true, + "type": "string" }, - "description": { - "type": "string", - "nullable": true + "licenses": { + "description": "The inforcer licences enabled for the tenant", + "items": { + "$ref": "#/components/schemas/tenantLicense" + }, + "type": "array" }, - "readOnly": { - "type": "boolean" + "msTenantId": { + "$ref": "#/components/schemas/msTenantId" }, - "product": { - "type": "string", - "description": "The product the policy's category belongs to" + "name": { + "description": "The tenant's display name", + "type": "string" }, - "primaryGroup": { + "policyDiff": { + "description": "A summary of the tenant's policy drift", + "nullable": true, "type": "string" }, - "secondaryGroup": { - "type": "string", - "nullable": true + "recentChanges": { + "description": "The number of policy changes detected recently", + "format": "int32", + "type": "integer" }, - "platform": { - "type": "string", - "nullable": true + "secureScore": { + "description": "The tenant's latest Microsoft Secure Score, or null when the tenant has not been scored", + "format": "double", + "nullable": true, + "type": "number" }, "tags": { - "type": "array", + "description": "The tags the client has added to the tenant in inforcer", "items": { - "$ref": "#/components/schemas/policyTag" - } - }, - "policyData": { - "type": "object", - "description": "The policy as Microsoft 365 returns it" + "$ref": "#/components/schemas/tenantTag" + }, + "type": "array" } - } - }, - "policyTag": { + }, "required": [ + "msTenantId", "name", - "description" + "dnsName", + "isBaseline", + "recentChanges", + "tags", + "alignmentSummaries", + "licenses" ], - "type": "object", + "type": "object" + }, + "tenantLicense": { + "description": "An inforcer licence enabled for a tenant, such as STANDARD_USER", "properties": { - "name": { + "sku": { + "description": "The license SKU", "type": "string" - }, - "description": { - "type": "string", - "nullable": true } - } + }, + "required": [ + "sku" + ], + "type": "object" }, - "secureScores": { + "tenantList": { + "description": "The client's own tenants in the API client's tenant scope. The list leaves out tenants that other clients share with the client", + "properties": { + "tenants": { + "description": "The tenants, with one entry per tenant", + "items": { + "$ref": "#/components/schemas/tenantListItem" + }, + "type": "array" + } + }, "required": [ - "currentScore", - "maxScore", - "currentScorePercentage", - "licensedUserCount", - "enabledServices", - "scores", - "controlProfiles", - "controlCategoryScores" + "tenants" ], - "type": "object", + "type": "object" + }, + "tenantListItem": { + "description": "A tenant in the API client's tenant scope, with its Secure Score, backup state, tags, alignment and licences", "properties": { - "currentScore": { - "type": "number", - "description": "The latest score, or null when the tenant has not been scored", - "format": "double", - "nullable": true + "alignmentSummaries": { + "description": "The tenant's alignment against each baseline it is a member of, empty when it is in no baseline", + "items": { + "$ref": "#/components/schemas/alignmentSummary" + }, + "type": "array" }, - "maxScore": { - "type": "number", - "description": "The highest score the tenant could reach", - "format": "double", - "nullable": true + "dnsName": { + "description": "The tenant's primary DNS name", + "type": "string" }, - "currentScorePercentage": { - "type": "number", - "description": "The latest score as a percentage of the maximum", - "format": "double", - "nullable": true + "isBaseline": { + "description": "Whether the tenant is a baseline", + "type": "boolean" }, - "licensedUserCount": { - "type": "integer", - "description": "The number of licensed users the latest score covers", + "lastBackupTimestamp": { + "description": "When the tenant was last backed up", + "format": "date-time", + "nullable": true, + "type": "string" + }, + "licenses": { + "description": "The inforcer licences enabled for the tenant", + "items": { + "$ref": "#/components/schemas/tenantLicense" + }, + "type": "array" + }, + "msTenantId": { + "$ref": "#/components/schemas/msTenantId" + }, + "name": { + "description": "The tenant's display name", + "type": "string" + }, + "policyDiff": { + "description": "A summary of the tenant's policy drift", + "nullable": true, + "type": "string" + }, + "recentChanges": { + "description": "The number of policy changes detected recently", "format": "int32", - "nullable": true + "type": "integer" }, - "enabledServices": { - "type": "array", + "secureScore": { + "description": "The tenant's latest Microsoft Secure Score, or null when the tenant has not been scored", + "format": "double", + "nullable": true, + "type": "number" + }, + "tags": { + "description": "The tags the client has added to the tenant in inforcer", "items": { - "type": "string" + "$ref": "#/components/schemas/tenantTag" }, - "description": "The Microsoft services the latest score covers" - }, - "scores": { - "type": "array", + "type": "array" + } + }, + "required": [ + "msTenantId", + "name", + "dnsName", + "isBaseline", + "recentChanges", + "tags", + "alignmentSummaries", + "licenses" + ], + "type": "object" + }, + "tenantPolicyMatch": { + "description": "A tenant policy that matches a baseline policy, with its differences from that policy", + "properties": { + "acceptedDeviations": { + "description": "Deviations accepted for this tenant policy, newest first", "items": { - "$ref": "#/components/schemas/secureScoreSnapshot" + "$ref": "#/components/schemas/acceptedDeviation" }, - "description": "The tenant's daily scores, latest first" + "type": "array" }, - "controlProfiles": { - "type": "array", + "id": { + "description": "The tenant policy's id in Microsoft 365", + "nullable": true, + "type": "string" + }, + "policyAssignmentsDiff": { + "description": "The assignments in which this tenant policy differs from the baseline policy, leaving out accepted deviations and values that client variables account for. Empty when none remain", "items": { - "$ref": "#/components/schemas/secureScoreControlProfile" + "$ref": "#/components/schemas/policyDiff" }, - "description": "The controls that would raise the latest score, most impactful first" + "type": "array" }, - "controlCategoryScores": { - "type": "array", + "policyDataDiff": { + "description": "The settings in which this tenant policy differs from the baseline policy, leaving out accepted deviations and values that client variables account for. Empty when none remain", "items": { - "$ref": "#/components/schemas/secureScoreControlCategory" + "$ref": "#/components/schemas/policyDiff" }, - "description": "The scores per control category" - } - } - }, - "secureScoreSnapshot": { - "required": [ - "currentScore", - "maxScore", - "currentScorePercentage", - "createdDateTime" - ], - "type": "object", - "properties": { - "currentScore": { - "type": "number", - "format": "double" - }, - "maxScore": { - "type": "number", - "format": "double" - }, - "currentScorePercentage": { - "type": "number", - "format": "double" + "type": "array" }, - "createdDateTime": { - "type": "string", - "description": "When Microsoft calculated the score, or null when Microsoft did not say", - "format": "date-time", - "nullable": true + "tags": { + "description": "The inforcer tags on the tenant policy", + "items": { + "$ref": "#/components/schemas/policyTag" + }, + "type": "array" } - } - }, - "secureScoreControlProfile": { + }, "required": [ "id", - "title", - "controlCategory", - "service", - "remediation", - "remediationImpact", - "actionUrl", - "maxScore", - "maxScorePercentage", - "currentScore", - "currentScorePercentage", - "scoreDifference", - "scoreDifferencePercentage" + "policyDataDiff", + "policyAssignmentsDiff", + "tags", + "acceptedDeviations" ], - "type": "object", + "type": "object" + }, + "tenantRole": { + "description": "A Microsoft Entra directory role definition of a tenant", "properties": { - "id": { - "type": "string", - "description": "Microsoft's id for the control" - }, - "title": { - "type": "string", - "nullable": true - }, - "controlCategory": { - "type": "string", - "description": "The category the control belongs to, such as Identity", - "nullable": true - }, - "service": { - "type": "string", - "description": "The Microsoft service the control applies to", - "nullable": true - }, - "remediation": { - "type": "string", - "description": "How to implement the control", - "nullable": true - }, - "remediationImpact": { - "type": "string", - "description": "The effect implementing the control has on users", - "nullable": true - }, - "actionUrl": { - "type": "string", - "description": "Where to implement the control", - "nullable": true + "description": { + "description": "The role's description", + "nullable": true, + "type": "string" }, - "maxScore": { - "type": "number", - "description": "The most the control can add to the score", - "format": "double" + "displayName": { + "description": "The role's display name", + "type": "string" }, - "maxScorePercentage": { - "type": "number", - "description": "The most the control can add, as a percentage of the maximum score", - "format": "double" + "id": { + "description": "The role definition's id", + "type": "string" }, - "currentScore": { - "type": "number", - "format": "double" + "isBuiltIn": { + "description": "Whether Microsoft defines the role", + "type": "boolean" }, - "currentScorePercentage": { - "type": "number", - "format": "double" + "isEnabled": { + "description": "Whether the role is enabled", + "type": "boolean" }, - "scoreDifference": { - "type": "number", - "description": "The score still available from the control", - "format": "double" + "isPrivileged": { + "description": "Whether Microsoft classes the role as privileged", + "type": "boolean" }, - "scoreDifferencePercentage": { - "type": "number", - "format": "double" + "templateId": { + "description": "The id of the role template the definition is based on", + "nullable": true, + "type": "string" } - } - }, - "secureScoreControlCategory": { + }, "required": [ - "controlCategory", - "maxScore", - "currentScore", - "currentScorePercentage", - "historicScores" + "id", + "templateId", + "displayName", + "description", + "isBuiltIn", + "isEnabled", + "isPrivileged" ], - "type": "object", + "type": "object" + }, + "tenantRoleList": { + "description": "A tenant's Microsoft Entra directory role definitions, in one response, leaving out the roles Entra does not show because they cannot be assigned", "properties": { - "controlCategory": { - "type": "string" - }, - "maxScore": { - "type": "number", - "format": "double" - }, - "currentScore": { - "type": "number", - "format": "double" - }, - "currentScorePercentage": { - "type": "number", - "format": "double" - }, - "historicScores": { - "type": "array", + "roles": { + "description": "The tenant's role definitions", "items": { - "$ref": "#/components/schemas/secureScoreControlCategorySnapshot" + "$ref": "#/components/schemas/tenantRole" }, - "description": "The category's daily scores, latest first" + "type": "array" } - } - }, - "secureScoreControlCategorySnapshot": { + }, "required": [ - "maxScore", - "currentScore", - "currentScorePercentage", - "createdDateTime" + "roles" ], - "type": "object", + "type": "object" + }, + "tenantTag": { + "description": "A tag the client has added to a tenant in inforcer", "properties": { - "maxScore": { - "type": "number", - "format": "double" - }, - "currentScore": { - "type": "number", - "format": "double" - }, - "currentScorePercentage": { - "type": "number", - "format": "double" + "description": { + "description": "The tag's description, or an empty string when it has none", + "type": "string" }, - "createdDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "name": { + "description": "The tag's name", + "type": "string" } - } - }, - "assessmentRun": { + }, "required": [ - "assessmentId", "name", - "summary", - "results" + "description" ], - "type": "object", + "type": "object" + }, + "triggerReportRunItem": { + "description": "One report to run, with its output format and parameters", "properties": { - "assessmentId": { - "type": "string", - "description": "The id of the assessment that was run" - }, - "name": { - "type": "string", - "description": "The name of the assessment that was run", - "nullable": true + "collate": { + "default": false, + "description": "Whether to collate the tenants into one output, for a collatable report type", + "type": "boolean" }, - "summary": { - "$ref": "#/components/schemas/assessmentRunSummary" + "outputFormat": { + "description": "One of the report type's supportedOutputFormats, from GET /v1/reports/types", + "type": "string" }, - "results": { - "type": "array", - "items": { - "$ref": "#/components/schemas/assessmentCheckResult" + "parameters": { + "additionalProperties": { + "type": "string" }, - "description": "The result of each of the assessment's checks" + "description": "Values for the report type's requiredParameters, from GET /v1/reports/types, keyed by parameter key", + "type": "object" + }, + "type": { + "description": "The report type's key, from GET /v1/reports/types", + "type": "string" } - } - }, - "assessmentRunSummary": { + }, "required": [ - "total", - "assessed", - "passed", - "failed", - "notRun", - "score" + "type", + "outputFormat" ], - "type": "object", + "type": "object" + }, + "triggerReportRunRequest": { + "description": "A request to run one or more reports for one or more tenants", "properties": { - "total": { - "type": "integer", - "description": "The number of checks in the run", - "format": "int32" - }, - "assessed": { - "type": "integer", - "description": "The number of checks with an outcome, all but notRun", - "format": "int32" - }, - "passed": { - "type": "integer", - "description": "The number of checks that passed", - "format": "int32" - }, - "failed": { - "type": "integer", - "description": "The number of checks that failed", - "format": "int32" - }, - "notRun": { - "type": "integer", - "description": "The number of checks not assessed, through insufficient permissions or an error", - "format": "int32" + "msTenantIds": { + "description": "The Microsoft Entra tenant ids of the tenants to run the reports for", + "items": { + "$ref": "#/components/schemas/msTenantId" + }, + "minItems": 1, + "type": "array" }, - "score": { - "maximum": 100, - "minimum": 0, - "type": "integer", - "description": "Passed checks as a percentage of assessed checks, rounded down. Null when no check was assessed", - "format": "int32", - "nullable": true + "reports": { + "description": "The reports to run", + "items": { + "$ref": "#/components/schemas/triggerReportRunItem" + }, + "minItems": 1, + "type": "array" } }, - "description": "Counts of the run's checks by outcome" + "required": [ + "reports", + "msTenantIds" + ], + "type": "object" }, - "assessmentCheckResult": { + "triggerReportRunResponse": { + "description": "The report run that inforcer queued", + "properties": { + "reportRunId": { + "description": "The id of the queued report run", + "format": "uuid", + "type": "string" + } + }, "required": [ - "id", - "key", - "name", - "category", - "subCategory", - "description", - "importance", - "impact", - "rationale", - "remediation", - "findings", - "frameworks", - "tags", - "version", - "created", - "lastUpdated" + "reportRunId" ], - "type": "object", + "type": "object" + }, + "user": { + "description": "A Microsoft Entra user of a tenant, read from Microsoft Graph, with their groups, roles, devices and licences", "properties": { - "id": { + "accountEnabled": { + "description": "Whether the user can sign in", + "nullable": true, + "type": "boolean" + }, + "appRoleAssignments": { + "description": "The app roles the user holds through a direct assignment in enterprise applications", + "items": { + "$ref": "#/components/schemas/userAppRoleAssignment" + }, + "nullable": true, + "type": "array" + }, + "assignedLicenses": { + "description": "The licences assigned to the user, directly or through a group", + "items": { + "$ref": "#/components/schemas/userLicense" + }, + "nullable": true, + "type": "array" + }, + "businessPhones": { + "description": "The user's business phone numbers", + "items": { + "type": "string" + }, + "nullable": true, + "type": "array" + }, + "city": { + "description": "The city where the user is based", + "nullable": true, "type": "string" }, - "key": { - "type": "string", - "description": "The check's machine-readable key, such as ensure_mfa_enabled_for_all_users" + "companyName": { + "description": "The name of the company the user works for", + "nullable": true, + "type": "string" }, - "name": { + "country": { + "description": "The country or region where the user is based, such as United Kingdom", + "nullable": true, "type": "string" }, - "category": { - "type": "string", - "description": "The product area the check applies to, such as Entra or Exchange", - "nullable": true + "createdDateTime": { + "description": "When the user was created in Microsoft Entra, in UTC", + "format": "date-time", + "nullable": true, + "type": "string" }, - "subCategory": { - "type": "string", - "nullable": true + "creationType": { + "description": "How the user account was created, such as Invitation for a guest. Null for an account created as a work or school account", + "nullable": true, + "type": "string" }, - "description": { - "type": "string", - "nullable": true + "department": { + "description": "The department the user works in", + "nullable": true, + "type": "string" }, - "importance": { - "type": "string", - "description": "The check's severity, such as High or Medium", - "nullable": true + "devices": { + "description": "The devices the user owns", + "items": { + "$ref": "#/components/schemas/userDevice" + }, + "nullable": true, + "type": "array" }, - "impact": { - "type": "string", - "description": "The operational impact of applying the recommended configuration", - "nullable": true + "displayName": { + "description": "The user's name as shown in Microsoft Entra and address lists", + "nullable": true, + "type": "string" }, - "rationale": { - "type": "string", - "nullable": true + "employeeHireDate": { + "description": "When the user was hired or will start work, in UTC", + "format": "date-time", + "nullable": true, + "type": "string" }, - "remediation": { - "type": "string", - "description": "How to fix a failing result, in markdown", - "nullable": true + "employeeId": { + "description": "The user's employee id in their organisation", + "nullable": true, + "type": "string" }, - "findings": { - "$ref": "#/components/schemas/assessmentCheckFinding" + "employeeType": { + "description": "The kind of worker the user is, such as Employee or Contractor", + "nullable": true, + "type": "string" }, - "frameworks": { - "type": "array", + "givenName": { + "description": "The user's first name", + "nullable": true, + "type": "string" + }, + "groups": { + "description": "The groups the user is a transitive member of", "items": { - "$ref": "#/components/schemas/assessmentCheckFramework" + "$ref": "#/components/schemas/userGroup" }, - "description": "The frameworks that reference the check, such as a CIS Benchmark" + "nullable": true, + "type": "array" }, - "tags": { - "type": "array", + "id": { + "description": "The user's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" + }, + "imAddresses": { + "description": "The user's instant messaging addresses", "items": { "type": "string" - } + }, + "nullable": true, + "type": "array" }, - "version": { - "type": "integer", - "description": "The version of the check the evaluation used", - "format": "int64" + "isAllDevicesCompliant": { + "description": "Whether every device the user owns is compliant, or null when the user owns no devices or inforcer cannot read them", + "nullable": true, + "type": "boolean" }, - "created": { - "type": "string", - "description": "When the check was created", + "isCloudOnly": { + "description": "Whether the user exists only in Microsoft Entra, with no sync from on-premises Active Directory and no onPremisesImmutableId", + "nullable": true, + "type": "boolean" + }, + "isGlobalAdmin": { + "description": "Whether the user holds the Global Administrator role, directly or through a group", + "nullable": true, + "type": "boolean" + }, + "isHybrid": { + "description": "Whether the user is synced from on-premises Active Directory and has an onPremisesImmutableId", + "nullable": true, + "type": "boolean" + }, + "isMfaCapable": { + "description": "Null when the tenant's licence does not report MFA capability", + "nullable": true, + "type": "boolean" + }, + "isMfaRegistered": { + "description": "Null when the tenant's licence does not report MFA registration", + "nullable": true, + "type": "boolean" + }, + "jobTitle": { + "description": "The user's job title", + "nullable": true, + "type": "string" + }, + "lastPasswordChangeDateTime": { + "description": "When the user last changed their password, or when it was first set, in UTC", "format": "date-time", - "nullable": true + "nullable": true, + "type": "string" }, - "lastUpdated": { - "type": "string", - "description": "When the check was last updated", + "lastSignInDateTime": { + "description": "When the user last signed in interactively, in UTC. Null when the user has never signed in or the tenant has no Microsoft Entra ID P1 or P2 licence", "format": "date-time", - "nullable": true - } - } - }, - "assessmentCheckFinding": { - "required": [ - "compliant", - "status", - "message", - "scores" - ], - "type": "object", - "properties": { - "compliant": { - "type": "boolean", - "description": "Whether every evaluated object passes the check. False when the check's data could not be read, see status" + "nullable": true, + "type": "string" }, - "status": { - "enum": [ - "pass", - "fail", - "insufficientPermissions", - "error" - ], - "type": "string", - "description": "The check's outcome. insufficientPermissions and error mean it was not assessed. When null, compliant is the outcome", - "nullable": true + "legalAgeGroupClassification": { + "description": "The user's legal age group, as Microsoft Entra works it out from their age group and consent, such as Adult or MinorWithParentalConsent", + "nullable": true, + "type": "string" }, - "message": { - "type": "string", - "description": "A summary of the finding", - "nullable": true + "mail": { + "description": "The user's primary email address", + "nullable": true, + "type": "string" }, - "scores": { - "type": "array", - "items": { - "$ref": "#/components/schemas/assessmentCheckScore" - }, - "description": "The score of each object the check evaluated" - } - } - }, - "assessmentCheckScore": { - "required": [ - "objectId", - "objectName", - "score", - "passes", - "violations", - "warnings" - ], - "type": "object", - "properties": { - "objectId": { - "type": "string", - "description": "The id of the evaluated policy or setting" + "mailNickname": { + "description": "The user's mail alias", + "nullable": true, + "type": "string" }, - "objectName": { - "type": "string", - "nullable": true + "manager": { + "$ref": "#/components/schemas/userManager" }, - "score": { - "maximum": 100, - "minimum": 0, - "type": "number", - "description": "100 when the object is fully compliant, 0 when it is fully non-compliant", - "format": "double" + "mobilePhone": { + "description": "The user's primary mobile phone number", + "nullable": true, + "type": "string" }, - "passes": { - "type": "array", - "items": { - "type": "string" - } + "officeLocation": { + "description": "The user's office location", + "nullable": true, + "type": "string" }, - "violations": { - "type": "array", - "items": { - "type": "string" - } + "onPremisesDistinguishedName": { + "description": "The user's distinguished name in on-premises Active Directory", + "nullable": true, + "type": "string" }, - "warnings": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "assessmentCheckFramework": { - "required": [ - "name", - "metadata" - ], - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The framework's name, such as CIS Microsoft 365 Foundations Benchmark v6.0.0" + "onPremisesDomainName": { + "description": "The user's domain name in on-premises Active Directory, such as contoso.local", + "nullable": true, + "type": "string" }, - "metadata": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "The framework's fields for the check, such as control and level" - } - } - }, - "userList": { - "required": [ - "users", - "userCount", - "continuationToken" - ], - "type": "object", - "properties": { - "users": { - "type": "array", - "items": { - "$ref": "#/components/schemas/userSummary" - } + "onPremisesImmutableId": { + "description": "The id that links the user to their on-premises Active Directory account", + "nullable": true, + "type": "string" + }, + "onPremisesLastSyncDateTime": { + "description": "When the user was last synced from on-premises Active Directory, in UTC", + "format": "date-time", + "nullable": true, + "type": "string" + }, + "onPremisesSamAccountName": { + "description": "The user's sAMAccountName in on-premises Active Directory", + "nullable": true, + "type": "string" + }, + "onPremisesSecurityIdentifier": { + "description": "The user's security identifier in on-premises Active Directory", + "nullable": true, + "type": "string" + }, + "onPremisesSyncEnabled": { + "description": "True when the user syncs from on-premises Active Directory, false when sync has stopped, and null when the user has never synced", + "nullable": true, + "type": "boolean" }, - "userCount": { - "type": "integer", - "description": "The number of users that match, across every page, or null when Microsoft Graph does not report it for this page", - "format": "int64", - "nullable": true + "onPremisesUserPrincipalName": { + "description": "The user's user principal name in on-premises Active Directory", + "nullable": true, + "type": "string" }, - "continuationToken": { - "type": "string", - "description": "The token to fetch the next page, or null when this is the last page", - "nullable": true - } - } - }, - "userSummary": { - "required": [ - "id", - "displayName", - "userPrincipalName", - "userType", - "jobTitle", - "department", - "groupCount", - "roleCount", - "assignedLicenses", - "isGlobalAdmin", - "isAccountEnabled", - "isMfaRegistered", - "isMfaCapable" - ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The user's Microsoft Entra object id", - "format": "uuid", - "nullable": true + "otherMails": { + "description": "The user's additional email addresses, such as a personal address", + "items": { + "type": "string" + }, + "nullable": true, + "type": "array" }, - "displayName": { - "type": "string", - "nullable": true + "passwordPolicies": { + "description": "The password policies set on the user, such as DisablePasswordExpiration, separated by commas", + "nullable": true, + "type": "string" }, - "userPrincipalName": { - "type": "string", - "nullable": true + "postalCode": { + "description": "The postal code of the user's address", + "nullable": true, + "type": "string" }, - "userType": { - "type": "string", - "description": "Member or Guest", - "nullable": true + "preferredDataLocation": { + "description": "The geographic location where the user's Microsoft 365 data is stored, such as GBR, for a tenant with Multi-Geo", + "nullable": true, + "type": "string" }, - "jobTitle": { - "type": "string", - "nullable": true + "preferredLanguage": { + "description": "The user's preferred language, as an ISO 639-1 code with a country code, such as en-GB", + "nullable": true, + "type": "string" }, - "department": { - "type": "string", - "nullable": true + "proxyAddresses": { + "description": "The user's email addresses for Exchange Online, such as SMTP:jo.bloggs@contoso.com. The uppercase SMTP prefix marks the primary address", + "items": { + "type": "string" + }, + "nullable": true, + "type": "array" }, - "groupCount": { - "type": "integer", - "description": "The number of groups the user is a member of", - "format": "int32" + "riskDetail": { + "description": "Null when the tenant's licence does not report risk", + "nullable": true, + "type": "string" }, - "roleCount": { - "type": "integer", - "description": "The number of directory roles assigned to the user", - "format": "int32" + "riskLevel": { + "description": "Null when the tenant's licence does not report risk", + "nullable": true, + "type": "string" }, - "assignedLicenses": { - "type": "array", + "riskState": { + "description": "Null when the tenant's licence does not report risk", + "nullable": true, + "type": "string" + }, + "roles": { + "description": "The directory roles assigned to the user", "items": { - "$ref": "#/components/schemas/userLicense" - } + "$ref": "#/components/schemas/userRole" + }, + "nullable": true, + "type": "array" }, - "isGlobalAdmin": { - "type": "boolean", - "nullable": true + "signInSessionsValidFromDateTime": { + "description": "The time before which refresh tokens and session cookies are invalid, in UTC. Revoking the user's sessions resets it to the current time", + "format": "date-time", + "nullable": true, + "type": "string" }, - "isAccountEnabled": { - "type": "boolean", - "nullable": true + "state": { + "description": "The state or province in the user's address", + "nullable": true, + "type": "string" }, - "isMfaRegistered": { - "type": "boolean", - "description": "Null when the tenant's licence does not report MFA registration", - "nullable": true + "streetAddress": { + "description": "The street address of the user's place of work", + "nullable": true, + "type": "string" }, - "isMfaCapable": { - "type": "boolean", - "description": "Null when the tenant's licence does not report MFA capability", - "nullable": true + "surname": { + "description": "The user's last name", + "nullable": true, + "type": "string" + }, + "usageLocation": { + "description": "The ISO 3166 two-letter country code where the user's licences are used, such as GB", + "nullable": true, + "type": "string" + }, + "userPrincipalName": { + "description": "The user's sign-in name, such as jo.bloggs@contoso.com", + "nullable": true, + "type": "string" + }, + "userType": { + "description": "Member or Guest", + "nullable": true, + "type": "string" } - } - }, - "user": { + }, "required": [ "id", "displayName", @@ -3122,1307 +3179,1608 @@ "appRoleAssignments", "assignedLicenses" ], - "type": "object", + "type": "object" + }, + "userAppRoleAssignment": { + "description": "An app role that the user holds in an application, as Microsoft Entra records it", "properties": { - "id": { - "type": "string", - "description": "The user's Microsoft Entra object id", + "appRoleId": { + "description": "The id of the app role granted. An id of all zeros means default access to the application, with no specific role", "format": "uuid", - "nullable": true + "nullable": true, + "type": "string" }, - "displayName": { - "type": "string", - "nullable": true + "principalDisplayName": { + "description": "The display name of the user, group or service principal the role is granted to", + "nullable": true, + "type": "string" }, - "givenName": { - "type": "string", - "nullable": true + "principalId": { + "description": "The Microsoft Entra object id of the user, group or service principal the role is granted to", + "format": "uuid", + "nullable": true, + "type": "string" }, - "surname": { - "type": "string", - "nullable": true + "principalType": { + "description": "The kind of principal the role is granted to, such as User, Group or ServicePrincipal", + "nullable": true, + "type": "string" }, - "userPrincipalName": { - "type": "string", - "nullable": true + "resourceDisplayName": { + "description": "The display name of the application's service principal that defines the role", + "nullable": true, + "type": "string" }, - "userType": { - "type": "string", - "description": "Member or Guest", - "nullable": true + "resourceId": { + "description": "The Microsoft Entra object id of the application's service principal that defines the role", + "format": "uuid", + "nullable": true, + "type": "string" + } + }, + "required": [ + "appRoleId", + "principalDisplayName", + "principalId", + "principalType", + "resourceDisplayName", + "resourceId" + ], + "type": "object" + }, + "userDevice": { + "description": "A Microsoft Entra device the user owns, as Microsoft Entra records it", + "properties": { + "complianceExpiryDateTime": { + "description": "When the device's compliance expires", + "format": "date-time", + "nullable": true, + "type": "string" }, - "jobTitle": { - "type": "string", - "nullable": true + "deviceCategory": { + "description": "The device's category in Intune", + "nullable": true, + "type": "string" }, - "department": { - "type": "string", - "nullable": true + "deviceOwnership": { + "description": "Whether the device is company or personal, as Intune sets it", + "nullable": true, + "type": "string" }, - "mail": { - "type": "string", - "nullable": true + "displayName": { + "description": "The device's name", + "nullable": true, + "type": "string" }, - "mobilePhone": { - "type": "string", - "nullable": true + "id": { + "description": "The device's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" }, - "businessPhones": { - "type": "array", - "items": { - "type": "string" - }, - "nullable": true + "isCompliant": { + "description": "Whether the device complies with its Intune compliance policies", + "nullable": true, + "type": "boolean" }, - "officeLocation": { - "type": "string", - "nullable": true + "isManaged": { + "description": "Whether a mobile device management app, such as Intune, manages the device", + "nullable": true, + "type": "boolean" }, - "streetAddress": { - "type": "string", - "nullable": true + "isManagementRestricted": { + "description": "Whether the device is in a restricted management administrative unit, so that only roles scoped to that unit can manage it", + "nullable": true, + "type": "boolean" }, - "city": { - "type": "string", - "nullable": true + "isRooted": { + "description": "Whether the device is rooted or jailbroken, as Intune reports it", + "nullable": true, + "type": "boolean" }, - "state": { - "type": "string", - "nullable": true + "managementType": { + "description": "The channel that manages the device, as Intune sets it, such as mdm or eas", + "nullable": true, + "type": "string" }, - "postalCode": { - "type": "string", - "nullable": true + "manufacturer": { + "description": "The device's manufacturer", + "nullable": true, + "type": "string" }, - "country": { - "type": "string", - "nullable": true + "model": { + "description": "The device's model", + "nullable": true, + "type": "string" }, - "preferredLanguage": { - "type": "string", - "nullable": true + "operatingSystem": { + "description": "The device's operating system, such as Windows, iOS or Android", + "nullable": true, + "type": "string" }, - "accountEnabled": { - "type": "boolean", - "nullable": true + "operatingSystemVersion": { + "description": "The version of the device's operating system", + "nullable": true, + "type": "string" }, - "usageLocation": { - "type": "string", - "nullable": true + "profileType": { + "description": "The kind of device profile, such as RegisteredDevice, SecureVM, Printer, Shared or IoT", + "nullable": true, + "type": "string" }, - "createdDateTime": { - "type": "string", + "registrationDateTime": { + "description": "When the device was registered in Microsoft Entra", "format": "date-time", - "nullable": true + "nullable": true, + "type": "string" }, - "lastPasswordChangeDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "trustType": { + "description": "How the device joins Microsoft Entra: Workplace for registered, AzureAd for Microsoft Entra joined, or ServerAd for hybrid joined", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id", + "complianceExpiryDateTime", + "deviceCategory", + "deviceOwnership", + "displayName", + "isCompliant", + "isManaged", + "isManagementRestricted", + "isRooted", + "managementType", + "manufacturer", + "model", + "operatingSystem", + "operatingSystemVersion", + "profileType", + "registrationDateTime", + "trustType" + ], + "type": "object" + }, + "userGroup": { + "description": "A Microsoft Entra group the user is a member of, directly or through another group", + "properties": { + "description": { + "description": "The group's description, or null when it has none", + "nullable": true, + "type": "string" }, - "lastSignInDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "displayName": { + "description": "The group's display name", + "type": "string" }, - "companyName": { - "type": "string", - "nullable": true + "groupTypes": { + "description": "The group's Microsoft Entra group types, such as Unified for a Microsoft 365 group or DynamicMembership for a dynamic group. Empty for a static security group or a distribution list", + "items": { + "type": "string" + }, + "type": "array" }, - "employeeId": { - "type": "string", - "nullable": true + "id": { + "description": "The group's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id", + "displayName", + "description", + "groupTypes" + ], + "type": "object" + }, + "userLicense": { + "description": "A licence assigned to the user, with the state of the tenant's subscription to its SKU", + "properties": { + "capabilityStatus": { + "description": "The state of the tenant's subscription to the SKU, such as Enabled, Warning, Suspended or LockedOut. Null when the SKU is not among the tenant's subscribed SKUs", + "nullable": true, + "type": "string" }, - "employeeType": { - "type": "string", - "nullable": true + "isCancelled": { + "description": "Whether the tenant's subscription to the SKU is locked out, which is a capabilityStatus of LockedOut. Null when capabilityStatus is null", + "nullable": true, + "type": "boolean" + }, + "isExpired": { + "description": "Whether the tenant's subscription to the SKU is suspended, which is a capabilityStatus of Suspended. Null when capabilityStatus is null", + "nullable": true, + "type": "boolean" }, - "employeeHireDate": { - "type": "string", - "format": "date-time", - "nullable": true + "name": { + "description": "The SKU's display name, or null when it has no known display name", + "nullable": true, + "type": "string" }, - "mailNickname": { - "type": "string", - "nullable": true + "sku": { + "description": "The SKU's part number, such as EXCHANGESTANDARD", + "nullable": true, + "type": "string" }, - "preferredDataLocation": { - "type": "string", - "nullable": true + "skuId": { + "description": "The SKU's Microsoft id", + "format": "uuid", + "nullable": true, + "type": "string" }, - "onPremisesSyncEnabled": { - "type": "boolean", - "nullable": true + "state": { + "description": "The state of the licence assignment", + "nullable": true, + "type": "string" + } + }, + "required": [ + "sku", + "skuId", + "name", + "capabilityStatus", + "isExpired", + "isCancelled", + "state" + ], + "type": "object" + }, + "userList": { + "description": "A page of a tenant's Microsoft Entra users, sorted by display name, with a continuationToken for the next page", + "properties": { + "continuationToken": { + "description": "The token to fetch the next page, or null when this is the last page", + "nullable": true, + "type": "string" }, - "otherMails": { - "type": "array", - "items": { - "type": "string" - }, - "nullable": true + "userCount": { + "description": "The number of users that match, across every page, or null when Microsoft Graph does not report it for this page", + "format": "int64", + "nullable": true, + "type": "integer" }, - "proxyAddresses": { - "type": "array", + "users": { + "description": "The users on this page, sorted by display name", "items": { - "type": "string" + "$ref": "#/components/schemas/userSummary" }, - "nullable": true - }, - "creationType": { - "type": "string", - "nullable": true - }, - "passwordPolicies": { - "type": "string", - "nullable": true + "type": "array" + } + }, + "required": [ + "users", + "userCount", + "continuationToken" + ], + "type": "object" + }, + "userManager": { + "description": "The user's manager, or null when the user has none", + "nullable": true, + "properties": { + "id": { + "description": "The manager's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id" + ], + "type": "object" + }, + "userRole": { + "description": "A Microsoft Entra directory role the user holds", + "properties": { + "displayName": { + "description": "The directory role's display name, such as Global Administrator", + "type": "string" }, - "signInSessionsValidFromDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "id": { + "description": "The directory role's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" }, - "imAddresses": { - "type": "array", + "roleTemplateId": { + "description": "The id of the role template the directory role is based on, which is the same in every tenant. Null when Microsoft Entra does not return a valid one", + "format": "uuid", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id", + "displayName", + "roleTemplateId" + ], + "type": "object" + }, + "userSummary": { + "description": "A Microsoft Entra user of a tenant, as the user list returns it, with counts of their groups and roles", + "properties": { + "assignedLicenses": { + "description": "The licences assigned to the user, directly or through a group", "items": { - "type": "string" + "$ref": "#/components/schemas/userLicense" }, - "nullable": true + "type": "array" }, - "legalAgeGroupClassification": { - "type": "string", - "nullable": true + "department": { + "description": "The department the user works in", + "nullable": true, + "type": "string" }, - "onPremisesLastSyncDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "displayName": { + "description": "The user's name as shown in Microsoft Entra and address lists", + "nullable": true, + "type": "string" }, - "onPremisesDistinguishedName": { - "type": "string", - "nullable": true + "groupCount": { + "description": "The number of groups the user is a member of", + "format": "int32", + "type": "integer" }, - "onPremisesDomainName": { - "type": "string", - "nullable": true + "id": { + "description": "The user's Microsoft Entra object id", + "format": "uuid", + "nullable": true, + "type": "string" }, - "onPremisesImmutableId": { - "type": "string", - "nullable": true + "isAccountEnabled": { + "description": "Whether the user can sign in", + "nullable": true, + "type": "boolean" }, - "onPremisesSecurityIdentifier": { - "type": "string", - "nullable": true + "isGlobalAdmin": { + "description": "Whether the user holds the Global Administrator role, directly or through a group", + "nullable": true, + "type": "boolean" }, - "onPremisesSamAccountName": { - "type": "string", - "nullable": true + "isMfaCapable": { + "description": "Null when the tenant's licence does not report MFA capability", + "nullable": true, + "type": "boolean" }, - "onPremisesUserPrincipalName": { - "type": "string", - "nullable": true + "isMfaRegistered": { + "description": "Null when the tenant's licence does not report MFA registration", + "nullable": true, + "type": "boolean" }, - "manager": { - "$ref": "#/components/schemas/userManager" + "jobTitle": { + "description": "The user's job title", + "nullable": true, + "type": "string" }, - "groups": { - "type": "array", - "items": { - "$ref": "#/components/schemas/userGroup" - }, - "description": "The groups the user is a transitive member of", - "nullable": true + "roleCount": { + "description": "The number of directory roles assigned to the user", + "format": "int32", + "type": "integer" }, - "roles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/userRole" - }, - "description": "The directory roles assigned to the user", - "nullable": true + "userPrincipalName": { + "description": "The user's sign-in name, such as jo.bloggs@contoso.com", + "nullable": true, + "type": "string" }, - "devices": { - "type": "array", - "items": { - "$ref": "#/components/schemas/userDevice" - }, - "description": "The devices the user owns", - "nullable": true + "userType": { + "description": "Member or Guest", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id", + "displayName", + "userPrincipalName", + "userType", + "jobTitle", + "department", + "groupCount", + "roleCount", + "assignedLicenses", + "isGlobalAdmin", + "isAccountEnabled", + "isMfaRegistered", + "isMfaCapable" + ], + "type": "object" + }, + "validationProblem": { + "allOf": [ + { + "$ref": "#/components/schemas/problem" }, - "isGlobalAdmin": { - "type": "boolean", - "nullable": true + { + "properties": { + "errors": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": "Validation messages keyed by the field they apply to", + "type": "object" + } + }, + "type": "object" + } + ], + "description": "A problem details object for a request that failed validation" + }, + "variableSubstitution": { + "description": "A client variable that inforcer substitutes at one place in a policy before it compares the policy", + "properties": { + "baselineValue": { + "description": "The variable's value for the baseline tenant, or null when it has none. Shows ***** when the variable is hidden", + "nullable": true, + "type": "string" }, - "isCloudOnly": { - "type": "boolean", - "nullable": true + "description": { + "description": "The client variable's description, or null when it has none", + "nullable": true, + "type": "string" }, - "isHybrid": { - "type": "boolean", - "nullable": true + "isBaselineOnly": { + "description": "Whether the variable was found only in the baseline policy", + "type": "boolean" }, - "isMfaRegistered": { - "type": "boolean", - "description": "Null when the tenant's licence does not report MFA registration", - "nullable": true + "isHidden": { + "description": "Whether the variable is hidden, in which case its values show as *****", + "type": "boolean" }, - "isMfaCapable": { - "type": "boolean", - "description": "Null when the tenant's licence does not report MFA capability", - "nullable": true + "name": { + "description": "The client variable's name", + "type": "string" }, - "isAllDevicesCompliant": { - "type": "boolean", - "nullable": true + "propertyPath": { + "description": "The JSON path the variable is substituted at", + "nullable": true, + "type": "string" }, - "riskState": { - "type": "string", - "description": "Null when the tenant's licence does not report risk", - "nullable": true + "tenantValue": { + "description": "The variable's value for the tenant, or null when it has none. Shows ***** when the variable is hidden", + "nullable": true, + "type": "string" + } + }, + "required": [ + "name", + "description", + "propertyPath", + "baselineValue", + "tenantValue", + "isHidden", + "isBaselineOnly" + ], + "type": "object" + } + }, + "securitySchemes": { + "oauth2": { + "description": "OAuth 2.0 client credentials. Exchange an API client's id and secret for a bearer token.", + "flows": { + "clientCredentials": { + "scopes": {}, + "tokenUrl": "/oauth/token" + } + }, + "type": "oauth2" + } + } + }, + "info": { + "title": "inforcer | Public API", + "version": "1.0.0" + }, + "openapi": "3.0.4", + "paths": { + "/v1/alignmentScores": { + "get": { + "description": "Lists the alignment of each licensed tenant in the API client's tenant scope against each of its baselines whose baseline tenant is also in that scope", + "operationId": "listAlignmentScores", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/alignmentScoreList" + } + } + }, + "description": "The alignment scores" }, - "riskDetail": { - "type": "string", - "description": "Null when the tenant's licence does not report risk", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "riskLevel": { - "type": "string", - "description": "Null when the tenant's licence does not report risk", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "appRoleAssignments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/userAppRoleAssignment" + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "List alignment scores", + "tags": [ + "Alignment scores" + ] + } + }, + "/v1/assessments": { + "get": { + "description": "Lists the assessments the client can run", + "operationId": "listAssessments", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/assessmentList" + } + } }, - "nullable": true + "description": "The assessments" }, - "assignedLicenses": { - "type": "array", - "items": { - "$ref": "#/components/schemas/userLicense" - }, - "nullable": true - } - } - }, - "userManager": { - "required": [ - "id" - ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The manager's Microsoft Entra object id", - "format": "uuid", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" + }, + "403": { + "$ref": "#/components/responses/forbidden" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } }, - "description": "The user's manager, or null when the user has none", - "nullable": true - }, - "userAppRoleAssignment": { - "required": [ - "appRoleId", - "principalDisplayName", - "principalId", - "principalType", - "resourceDisplayName", - "resourceId" - ], - "type": "object", - "properties": { - "appRoleId": { - "type": "string", - "format": "uuid", - "nullable": true + "summary": "List assessments", + "tags": [ + "Assessments" + ] + } + }, + "/v1/auditEvents/search": { + "post": { + "description": "Searches the client's activity log, newest first", + "operationId": "searchAuditEvents", + "requestBody": { + "content": { + "application/json": { + "example": { + "dateFrom": "2026-02-01T00:00:00Z", + "dateTo": "2026-02-26T23:59:59Z", + "eventTypes": [ + "authentication", + "failedAuthentication" + ], + "pageSize": 50 + }, + "schema": { + "$ref": "#/components/schemas/searchAuditEventsRequest" + } + } }, - "principalDisplayName": { - "type": "string", - "nullable": true + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/auditEventList" + } + } + }, + "description": "The matching audit events" }, - "principalId": { - "type": "string", - "format": "uuid", - "nullable": true + "400": { + "$ref": "#/components/responses/badRequest" }, - "principalType": { - "type": "string", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "resourceDisplayName": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "resourceId": { - "type": "string", - "format": "uuid", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "userGroup": { - "required": [ - "id", - "displayName", - "description", - "groupTypes" - ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The group's Microsoft Entra object id", - "format": "uuid", - "nullable": true + }, + "summary": "Search audit events", + "tags": [ + "Audit events" + ] + } + }, + "/v1/auditEvents/types": { + "get": { + "description": "Lists the types of events the activity log records", + "operationId": "listAuditEventTypes", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/auditEventTypeList" + } + } + }, + "description": "The audit event types" }, - "displayName": { - "type": "string" + "401": { + "$ref": "#/components/responses/unauthorized" }, - "description": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "groupTypes": { - "type": "array", - "items": { - "type": "string" + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "List audit event types", + "tags": [ + "Audit events" + ] + } + }, + "/v1/baselines": { + "get": { + "description": "Lists the client's baselines whose baseline tenant is in the API client's tenant scope. A baseline another client shares appears as the client's copy, marked by isSharedCopy", + "operationId": "listBaselines", + "parameters": [ + { + "description": "Only the baselines of this baseline tenant", + "in": "query", + "name": "baselineMsTenantId", + "schema": { + "$ref": "#/components/schemas/msTenantId" } } - } - }, - "userRole": { - "required": [ - "id", - "displayName", - "roleTemplateId" ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The directory role's Microsoft Entra object id", - "format": "uuid", - "nullable": true + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/baselineList" + } + } + }, + "description": "The baselines" }, - "displayName": { - "type": "string" + "400": { + "$ref": "#/components/responses/badRequest" }, - "roleTemplateId": { - "type": "string", - "format": "uuid", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" + }, + "403": { + "$ref": "#/components/responses/forbidden" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "userDevice": { - "required": [ - "id", - "complianceExpiryDateTime", - "deviceCategory", - "deviceOwnership", - "displayName", - "isCompliant", - "isManaged", - "isManagementRestricted", - "isRooted", - "managementType", - "manufacturer", - "model", - "operatingSystem", - "operatingSystemVersion", - "profileType", - "registrationDateTime", - "trustType" - ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The device's Microsoft Entra object id", - "format": "uuid", - "nullable": true + }, + "summary": "List baselines", + "tags": [ + "Baselines" + ] + } + }, + "/v1/reports/runs": { + "get": { + "description": "Lists the client's report runs from the last 7 days, newest first, up to 500. The list always includes runs that the API client or its owner user started. With permission to view others' report runs, it also includes scheduled runs and runs that others started, when the API client can run those reports on all of the run's tenants.", + "operationId": "listReportRuns", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/reportRunList" + } + } + }, + "description": "The report runs" }, - "complianceExpiryDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "deviceCategory": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "deviceOwnership": { - "type": "string", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "List report runs", + "tags": [ + "Reports" + ] + }, + "post": { + "description": "Queues a run of one or more reports for tenants in the API client's tenant scope. The API client needs the run permissions for each report type on every requested tenant, and every requested tenant must hold the licence that the report type needs. Otherwise the request returns a 403.", + "operationId": "triggerReportRun", + "requestBody": { + "content": { + "application/json": { + "example": { + "msTenantIds": [ + "2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091" + ], + "reports": [ + { + "outputFormat": "pdf", + "parameters": { + "report-period": "30" + }, + "type": "CopilotAdoption" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/triggerReportRunRequest" + } + } }, - "displayName": { - "type": "string", - "nullable": true + "required": true + }, + "responses": { + "202": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/triggerReportRunResponse" + } + } + }, + "description": "The report run is queued" }, - "isCompliant": { - "type": "boolean", - "nullable": true + "400": { + "$ref": "#/components/responses/badRequest" }, - "isManaged": { - "type": "boolean", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "isManagementRestricted": { - "type": "boolean", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "isRooted": { - "type": "boolean", - "nullable": true + "404": { + "$ref": "#/components/responses/notFound" }, - "managementType": { - "type": "string", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "Trigger report run", + "tags": [ + "Reports" + ] + } + }, + "/v1/reports/runs/{reportRunId}/outputs": { + "get": { + "description": "Lists the rendered outputs of a finished report run, for tenants where the API client can run that report type and the tenant holds its licence. The list includes a collated output only when those tenants include every tenant the run targeted", + "operationId": "listReportRunOutputs", + "parameters": [ + { + "description": "The report run's id", + "in": "path", + "name": "reportRunId", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/reportRunOutputList" + } + } + }, + "description": "The report run's outputs" }, - "manufacturer": { - "type": "string", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "model": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "operatingSystem": { - "type": "string", - "nullable": true + "404": { + "$ref": "#/components/responses/notFound" }, - "operatingSystemVersion": { - "type": "string", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "List report run outputs", + "tags": [ + "Reports" + ] + } + }, + "/v1/reports/runs/{reportRunId}/outputs/{outputId}": { + "get": { + "description": "Downloads the content of one output of a finished report run, for a tenant where the API client can run that report type and the tenant holds its licence. inforcer serves a collated output only when those tenants include every tenant the run targeted", + "operationId": "getReportRunOutput", + "parameters": [ + { + "description": "The report run's id", + "in": "path", + "name": "reportRunId", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } }, - "profileType": { - "type": "string", - "nullable": true + { + "description": "The output's id", + "in": "path", + "name": "outputId", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "format": "binary", + "type": "string" + } + }, + "application/pdf": { + "schema": { + "format": "binary", + "type": "string" + } + }, + "text/csv": { + "schema": { + "format": "binary", + "type": "string" + } + }, + "text/html": { + "schema": { + "format": "binary", + "type": "string" + } + } + }, + "description": "The output's content, in its format", + "headers": { + "Content-Disposition": { + "description": "The output's file name", + "schema": { + "type": "string" + } + } + } }, - "registrationDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "trustType": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" + }, + "404": { + "$ref": "#/components/responses/notFound" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "userLicense": { - "required": [ - "sku", - "skuId", - "name", - "capabilityStatus", - "isExpired", - "isCancelled", - "state" - ], - "type": "object", - "properties": { - "sku": { - "type": "string", - "description": "The SKU's part number, such as EXCHANGESTANDARD", - "nullable": true + }, + "summary": "Download a report run output", + "tags": [ + "Reports" + ] + } + }, + "/v1/reports/types": { + "get": { + "description": "Lists the report types the API client holds the run permissions for. Running one also needs each target tenant to hold the licence that the report type needs", + "operationId": "listReportTypes", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/reportTypeList" + } + } + }, + "description": "The report types" }, - "skuId": { - "type": "string", - "format": "uuid", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "name": { - "type": "string", - "description": "The SKU's display name, or null when it has no known display name", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "capabilityStatus": { - "type": "string", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "List report types", + "tags": [ + "Reports" + ] + } + }, + "/v1/tenants": { + "get": { + "description": "Lists the client's own tenants in the API client's tenant scope. The list leaves out tenants that other clients share with the client, which getTenant still returns", + "operationId": "listTenants", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/tenantList" + } + } + }, + "description": "The tenants" }, - "isExpired": { - "type": "boolean", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "isCancelled": { - "type": "boolean", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "state": { - "type": "string", - "description": "The state of the licence assignment", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "groupList": { - "required": [ - "groups", - "groupCount", - "continuationToken" - ], - "type": "object", - "properties": { - "groups": { - "type": "array", - "items": { - "$ref": "#/components/schemas/groupSummary" + }, + "summary": "List tenants", + "tags": [ + "Tenants" + ] + } + }, + "/v1/tenants/{msTenantId}": { + "get": { + "description": "Returns a tenant in the API client's tenant scope", + "operationId": "getTenant", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" } - }, - "groupCount": { - "type": "integer", - "description": "The number of groups that match, across every page", - "format": "int64" - }, - "continuationToken": { - "type": "string", - "description": "The token to fetch the next page, or null when this is the last page", - "nullable": true } - } - }, - "groupSummary": { - "required": [ - "id", - "displayName", - "description", - "mail", - "visibility", - "membershipRule", - "groupTypes" ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The group's Microsoft Entra object id", - "format": "uuid", - "nullable": true + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/tenantDetail" + } + } + }, + "description": "The tenant" }, - "displayName": { - "type": "string", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "description": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "mail": { - "type": "string", - "nullable": true + "404": { + "$ref": "#/components/responses/notFound" }, - "visibility": { - "type": "string", - "description": "Public, Private or HiddenMembership", - "nullable": true + "409": { + "$ref": "#/components/responses/conflict" }, - "membershipRule": { - "type": "string", - "description": "The rule for a dynamic group's members, or null for an assigned group", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "Get tenant", + "tags": [ + "Tenants" + ] + } + }, + "/v1/tenants/{msTenantId}/alignmentDetails": { + "get": { + "description": "Compares a tenant's policies with a baseline it is aligned against", + "operationId": "getTenantAlignmentDetails", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" + } }, - "groupTypes": { - "type": "array", - "items": { + { + "description": "The baseline's id, as in listBaselines", + "in": "query", + "name": "baselineId", + "required": true, + "schema": { + "format": "uuid", "type": "string" } } - } - }, - "group": { - "required": [ - "id", - "displayName", - "description", - "mail", - "mailNickname", - "visibility", - "membershipRule", - "groupTypes", - "createdDateTime", - "mailEnabled", - "onPremisesSyncEnabled" ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The group's Microsoft Entra object id", - "format": "uuid", - "nullable": true + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/alignmentDetails" + } + } + }, + "description": "The tenant's alignment with the baseline" }, - "displayName": { - "type": "string", - "nullable": true + "400": { + "$ref": "#/components/responses/badRequest" }, - "description": { - "type": "string", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "mail": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "mailNickname": { - "type": "string", - "nullable": true + "404": { + "$ref": "#/components/responses/notFound" }, - "visibility": { - "type": "string", - "description": "Public, Private or HiddenMembership", - "nullable": true + "409": { + "$ref": "#/components/responses/conflict" }, - "membershipRule": { - "type": "string", - "description": "The rule for a dynamic group's members, or null for an assigned group", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "Get tenant alignment details", + "tags": [ + "Alignment details" + ] + } + }, + "/v1/tenants/{msTenantId}/assessments/{assessmentId}/runs": { + "post": { + "description": "Runs an assessment against a tenant and returns the result of each of its checks", + "operationId": "runTenantAssessment", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" + } }, - "groupTypes": { - "type": "array", - "items": { + { + "description": "The id of the assessment to run", + "in": "path", + "name": "assessmentId", + "required": true, + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/assessmentRun" + } + } + }, + "description": "The assessment's results" }, - "createdDateTime": { - "type": "string", - "format": "date-time", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "mailEnabled": { - "type": "boolean", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "onPremisesSyncEnabled": { - "type": "boolean", - "nullable": true - } - } - }, - "groupMemberList": { - "required": [ - "members", - "memberCount", - "continuationToken" - ], - "type": "object", - "properties": { - "members": { - "type": "array", - "items": { - "$ref": "#/components/schemas/groupMember" - } + "404": { + "$ref": "#/components/responses/notFound" }, - "memberCount": { - "type": "integer", - "description": "The number of the group's direct members, across every page, or null when Microsoft Graph does not report it for this page", - "format": "int64", - "nullable": true + "409": { + "$ref": "#/components/responses/conflict" }, - "continuationToken": { - "type": "string", - "description": "The token to fetch the next page, or null when this is the last page", - "nullable": true - } - } - }, - "groupMember": { - "required": [ - "id", - "displayName", - "type" - ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The member's Microsoft Entra object id", - "format": "uuid", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" }, - "displayName": { - "type": "string", - "nullable": true + "500": { + "$ref": "#/components/responses/internalServerError" }, - "type": { - "type": "string", - "description": "The member's OData type, such as #microsoft.graph.user", - "nullable": true + "502": { + "$ref": "#/components/responses/badGateway" } - } - }, - "triggerReportRunRequest": { - "required": [ - "reports", - "msTenantIds" - ], - "type": "object", - "properties": { - "reports": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/components/schemas/triggerReportRunItem" - } - }, - "msTenantIds": { - "minItems": 1, - "type": "array", - "items": { + }, + "summary": "Run tenant assessment", + "tags": [ + "Assessments" + ] + } + }, + "/v1/tenants/{msTenantId}/directoryRoles": { + "get": { + "description": "Lists a tenant's Microsoft Entra directory role definitions", + "operationId": "listTenantRoles", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { "$ref": "#/components/schemas/msTenantId" } } - } - }, - "triggerReportRunItem": { - "required": [ - "type", - "outputFormat" ], - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "The report type's key, from GET /v1/reports/types" + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/tenantRoleList" + } + } + }, + "description": "The tenant's role definitions" }, - "outputFormat": { - "type": "string", - "description": "One of the report type's supportedOutputFormats, from GET /v1/reports/types" + "401": { + "$ref": "#/components/responses/unauthorized" }, - "collate": { - "type": "boolean", - "description": "Whether to collate the tenants into one output, for a collatable report type", - "default": false + "403": { + "$ref": "#/components/responses/forbidden" }, - "parameters": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Values for the report type's requiredParameters, from GET /v1/reports/types, keyed by parameter key" - } - } - }, - "triggerReportRunResponse": { - "required": [ - "reportRunId" - ], - "type": "object", - "properties": { - "reportRunId": { - "type": "string", - "description": "The id of the queued report run", - "format": "uuid" + "404": { + "$ref": "#/components/responses/notFound" + }, + "409": { + "$ref": "#/components/responses/conflict" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "reportRunList": { - "required": [ - "reportRuns" - ], - "type": "object", - "properties": { - "reportRuns": { - "type": "array", - "items": { - "$ref": "#/components/schemas/reportRun" + }, + "summary": "List tenant roles", + "tags": [ + "Roles" + ] + } + }, + "/v1/tenants/{msTenantId}/groups": { + "get": { + "description": "Lists a tenant's Microsoft Entra groups, a page at a time", + "operationId": "listTenantGroups", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" } - } - } - }, - "reportRun": { - "required": [ - "reportRunId", - "status", - "reportTypes", - "outputFormats", - "triggeredByType", - "createdAt", - "startedAt", - "completedAt", - "outputCount" - ], - "type": "object", - "properties": { - "reportRunId": { - "type": "string", - "format": "uuid" - }, - "status": { - "enum": [ - "pending", - "running", - "completed", - "completedWithErrors", - "failed" - ], - "type": "string" }, - "reportTypes": { - "type": "array", - "items": { + { + "description": "Only groups whose display name matches this term", + "in": "query", + "name": "search", + "schema": { "type": "string" - }, - "description": "The keys of the report types the run covers" + } }, - "outputFormats": { - "type": "array", - "items": { + { + "description": "The token from the previous page, to fetch the next one", + "in": "query", + "name": "continuationToken", + "schema": { "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/groupList" + } + } }, - "description": "The output formats the run produces. New formats may be added." + "description": "A page of up to 20 of the tenant's groups" }, - "triggeredByType": { - "enum": [ - "user", - "scheduled" - ], - "type": "string" + "400": { + "$ref": "#/components/responses/badRequest" }, - "createdAt": { - "type": "string", - "format": "date-time" + "401": { + "$ref": "#/components/responses/unauthorized" }, - "startedAt": { - "type": "string", - "description": "Null until rendering starts", - "format": "date-time", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "completedAt": { - "type": "string", - "description": "Null until the run reaches a terminal status", - "format": "date-time", - "nullable": true + "404": { + "$ref": "#/components/responses/notFound" }, - "outputCount": { - "minimum": 0, - "type": "integer", - "description": "The number of successful outputs. Null while running, or for a failed run with no outputs.", - "nullable": true + "409": { + "$ref": "#/components/responses/conflict" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "reportRunOutputList": { - "required": [ - "outputs" - ], - "type": "object", - "properties": { - "outputs": { - "type": "array", - "items": { - "$ref": "#/components/schemas/reportRunOutput" + }, + "summary": "List tenant groups", + "tags": [ + "Groups" + ] + } + }, + "/v1/tenants/{msTenantId}/groups/{groupId}": { + "get": { + "description": "Gets a tenant's Microsoft Entra group", + "operationId": "getTenantGroup", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" } - } - } - }, - "reportRunOutput": { - "required": [ - "id", - "reportType", - "msTenantId", - "format", - "sizeBytes" - ], - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The output's id", - "format": "uuid" - }, - "reportType": { - "type": "string", - "description": "The report type's key" - }, - "msTenantId": { - "anyOf": [ - { - "$ref": "#/components/schemas/msTenantId" - }, - { - "enum": [ - null - ], - "type": "string", - "nullable": true - } - ], - "description": "The tenant the output covers, or null for an output collated across tenants" - }, - "format": { - "type": "string", - "description": "The output format, such as csv, json, html or pdf" }, - "sizeBytes": { - "type": "integer", - "description": "The output's size in bytes, or null when it was not recorded", - "format": "int64", - "nullable": true - } - } - }, - "reportTypeList": { - "required": [ - "reportTypes" - ], - "type": "object", - "properties": { - "reportTypes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/reportType" + { + "description": "The group's Microsoft Entra object id", + "in": "path", + "name": "groupId", + "required": true, + "schema": { + "format": "uuid", + "type": "string" } } - } - }, - "reportType": { - "required": [ - "key", - "name", - "description", - "collatable", - "singleTenantOnly", - "supportedOutputFormats", - "tags", - "requiredParameters" ], - "type": "object", - "properties": { - "key": { - "type": "string", - "description": "The report type's key" + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/group" + } + } + }, + "description": "The group" }, - "name": { - "type": "string" + "401": { + "$ref": "#/components/responses/unauthorized" }, - "description": { - "type": "string", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "collatable": { - "type": "boolean", - "description": "Whether a run can collate its tenants into one output" + "404": { + "$ref": "#/components/responses/notFound" }, - "singleTenantOnly": { - "type": "boolean", - "description": "Whether a run can include only one tenant" + "409": { + "$ref": "#/components/responses/conflict" }, - "supportedOutputFormats": { - "type": "array", - "items": { - "type": "string" + "429": { + "$ref": "#/components/responses/tooManyRequests" + } + }, + "summary": "Get tenant group", + "tags": [ + "Groups" + ] + } + }, + "/v1/tenants/{msTenantId}/groups/{groupId}/members": { + "get": { + "description": "Lists a tenant's Microsoft Entra group's direct members, a page at a time", + "operationId": "listTenantGroupMembers", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" } }, - "tags": { - "type": "array", - "items": { + { + "description": "The group's Microsoft Entra object id", + "in": "path", + "name": "groupId", + "required": true, + "schema": { + "format": "uuid", "type": "string" } }, - "requiredParameters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/reportParameter" + { + "description": "The token from the previous page, to fetch the next one", + "in": "query", + "name": "continuationToken", + "schema": { + "type": "string" } } - } - }, - "reportParameter": { - "required": [ - "key", - "description", - "options" ], - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "description": { - "type": "string" - }, - "options": { - "type": "array", - "items": { - "$ref": "#/components/schemas/reportParameterOption" + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/groupMemberList" + } + } }, - "description": "The values the parameter accepts, or null when it accepts any value", - "nullable": true - } - } - }, - "reportParameterOption": { - "required": [ - "key", - "description" - ], - "type": "object", - "properties": { - "key": { - "type": "string" + "description": "A page of up to 100 of the group's direct members" }, - "description": { - "type": "string" - } - } - }, - "auditEventTypeList": { - "required": [ - "eventTypes" - ], - "type": "object", - "properties": { - "eventTypes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/auditEventType" - } - } - } - }, - "auditEventType": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The event type's name" - } - } - }, - "searchAuditEventsRequest": { - "type": "object", - "properties": { - "user": { - "type": "string", - "description": "Only events by this user", - "nullable": true + "400": { + "$ref": "#/components/responses/badRequest" }, - "eventTypes": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Only events of these types", - "nullable": true + "401": { + "$ref": "#/components/responses/unauthorized" }, - "dateFrom": { - "type": "string", - "description": "Only events at or after this time, in whole seconds", - "format": "date-time", - "nullable": true + "403": { + "$ref": "#/components/responses/forbidden" }, - "dateTo": { - "type": "string", - "description": "Only events at or before the end of this second, in whole seconds", - "format": "date-time", - "nullable": true + "404": { + "$ref": "#/components/responses/notFound" }, - "pageSize": { - "maximum": 100, - "minimum": 1, - "type": "integer", - "description": "The most events to return in one page", - "format": "int32", - "default": 25, - "nullable": true + "409": { + "$ref": "#/components/responses/conflict" }, - "continuationToken": { - "type": "string", - "description": "The token from the previous page, to fetch the next one", - "nullable": true + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } - }, - "auditEventList": { - "required": [ - "auditEvents", - "continuationToken" - ], - "type": "object", - "properties": { - "auditEvents": { - "type": "array", - "items": { - "$ref": "#/components/schemas/auditEvent" + }, + "summary": "List tenant group members", + "tags": [ + "Groups" + ] + } + }, + "/v1/tenants/{msTenantId}/policies": { + "get": { + "description": "Lists the policies of a tenant in the API client's tenant scope, in inforcer's policy format", + "operationId": "listTenantPolicies", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, + "schema": { + "$ref": "#/components/schemas/msTenantId" } - }, - "continuationToken": { - "type": "string", - "description": "The token to fetch the next page, or null when this is the last page", - "nullable": true } - } - }, - "auditEvent": { - "required": [ - "id", - "correlationId", - "relType", - "relId", - "eventType", - "code", - "user", - "timestamp", - "metadata" ], - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "correlationId": { - "type": "string", - "description": "Shared by events that belong to the same operation", - "format": "uuid", - "nullable": true - }, - "relType": { - "type": "string", - "description": "The type of the entity the event relates to", - "nullable": true - }, - "relId": { - "type": "string", - "description": "The id of the entity the event relates to", - "nullable": true + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/policyList" + } + } + }, + "description": "The tenant's policies, in inforcer's policy format" }, - "eventType": { - "type": "string" + "401": { + "$ref": "#/components/responses/unauthorized" }, - "code": { - "type": "string", - "description": "What happened, within the event type" + "403": { + "$ref": "#/components/responses/forbidden" }, - "user": { - "type": "string", - "description": "Who caused the event" + "404": { + "$ref": "#/components/responses/notFound" }, - "timestamp": { - "type": "string", - "format": "date-time" + "409": { + "$ref": "#/components/responses/conflict" }, - "metadata": { - "type": "object", - "description": "The event's details, which vary by event type" + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } + }, + "summary": "List tenant policies", + "tags": [ + "Policies" + ] } }, - "responses": { - "badRequest": { - "description": "The request is invalid", - "content": { - "application/problem+json": { + "/v1/tenants/{msTenantId}/secureScores": { + "get": { + "description": "Gets a tenant's Microsoft Secure Score, its history and the controls that would raise it", + "operationId": "getTenantSecureScores", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, "schema": { - "$ref": "#/components/schemas/validationProblem" + "$ref": "#/components/schemas/msTenantId" } } - } - }, - "unauthorized": { - "description": "The bearer token is missing, invalid or expired", - "headers": { - "WWW-Authenticate": { - "description": "The Bearer challenge", - "schema": { - "type": "string" - } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/secureScores" + } + } + }, + "description": "The tenant's secure scores" + }, + "401": { + "$ref": "#/components/responses/unauthorized" + }, + "403": { + "$ref": "#/components/responses/forbidden" + }, + "404": { + "$ref": "#/components/responses/notFound" + }, + "409": { + "$ref": "#/components/responses/conflict" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } }, - "content": { - "application/problem+json": { - "schema": { - "$ref": "#/components/schemas/problem" - } - } - } - }, - "forbidden": { - "description": "The API client lacks the permission or tenant scope for this request", - "content": { - "application/problem+json": { + "summary": "Get tenant secure scores", + "tags": [ + "Secure scores" + ] + } + }, + "/v1/tenants/{msTenantId}/users": { + "get": { + "description": "Lists a tenant's Microsoft Entra users by display name, a page at a time", + "operationId": "listTenantUsers", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, "schema": { - "$ref": "#/components/schemas/problem" + "$ref": "#/components/schemas/msTenantId" } - } - } - }, - "notFound": { - "description": "The resource does not exist or is outside the API client's tenant scope", - "content": { - "application/problem+json": { + }, + { + "description": "Only users whose name or user principal name matches this term", + "in": "query", + "name": "search", "schema": { - "$ref": "#/components/schemas/problem" + "type": "string" } - } - } - }, - "conflict": { - "description": "The request conflicts with the resource's current state", - "content": { - "application/problem+json": { + }, + { + "description": "The token from the previous page, to fetch the next one", + "in": "query", + "name": "continuationToken", "schema": { - "$ref": "#/components/schemas/problem" + "type": "string" } } - } - }, - "tooManyRequests": { - "description": "The rate limit is exceeded", - "headers": { - "Retry-After": { - "description": "Seconds to wait before retrying", - "schema": { - "type": "integer" - } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/userList" + } + } + }, + "description": "A page of up to 200 of the tenant's users" + }, + "400": { + "$ref": "#/components/responses/badRequest" + }, + "401": { + "$ref": "#/components/responses/unauthorized" + }, + "403": { + "$ref": "#/components/responses/forbidden" + }, + "404": { + "$ref": "#/components/responses/notFound" + }, + "409": { + "$ref": "#/components/responses/conflict" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } }, - "content": { - "application/problem+json": { - "schema": { - "$ref": "#/components/schemas/problem" - } - } - } - }, - "internalServerError": { - "description": "An unexpected error occurred", - "content": { - "application/problem+json": { + "summary": "List tenant users", + "tags": [ + "Users" + ] + } + }, + "/v1/tenants/{msTenantId}/users/{userId}": { + "get": { + "description": "Gets a tenant's Microsoft Entra user, with their groups, roles and devices", + "operationId": "getTenantUser", + "parameters": [ + { + "description": "The tenant's Microsoft Entra tenant id", + "in": "path", + "name": "msTenantId", + "required": true, "schema": { - "$ref": "#/components/schemas/problem" + "$ref": "#/components/schemas/msTenantId" } - } - } - }, - "badGateway": { - "description": "A service the request depends on failed", - "content": { - "application/problem+json": { + }, + { + "description": "The user's Microsoft Entra object id", + "in": "path", + "name": "userId", + "required": true, "schema": { - "$ref": "#/components/schemas/problem" + "format": "uuid", + "type": "string" } } - } - } - }, - "securitySchemes": { - "oauth2": { - "type": "oauth2", - "description": "OAuth 2.0 client credentials. Exchange an API client's id and secret for a bearer token.", - "flows": { - "clientCredentials": { - "tokenUrl": "/oauth/token", - "scopes": {} + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/user" + } + } + }, + "description": "The user" + }, + "401": { + "$ref": "#/components/responses/unauthorized" + }, + "403": { + "$ref": "#/components/responses/forbidden" + }, + "404": { + "$ref": "#/components/responses/notFound" + }, + "409": { + "$ref": "#/components/responses/conflict" + }, + "429": { + "$ref": "#/components/responses/tooManyRequests" } - } + }, + "summary": "Get tenant user", + "tags": [ + "Users" + ] } } }, @@ -4433,52 +4791,52 @@ ], "tags": [ { - "name": "Tenants", - "description": "The tenants an API client can access" + "description": "The tenants an API client can access", + "name": "Tenants" }, { - "name": "Policies", - "description": "The policies of a tenant" + "description": "The policies of a tenant", + "name": "Policies" }, { - "name": "Secure scores", - "description": "The Microsoft Secure Score of a tenant" + "description": "The Microsoft Secure Score of a tenant", + "name": "Secure scores" }, { - "name": "Users", - "description": "The Microsoft Entra users of a tenant" + "description": "The Microsoft Entra users of a tenant", + "name": "Users" }, { - "name": "Groups", - "description": "The Microsoft Entra groups of a tenant" + "description": "The Microsoft Entra groups of a tenant", + "name": "Groups" }, { - "name": "Roles", - "description": "The Entra directory roles of a tenant" + "description": "The Entra directory roles of a tenant", + "name": "Roles" }, { - "name": "Baselines", - "description": "The baselines tenants are aligned against" + "description": "The baselines tenants are aligned against", + "name": "Baselines" }, { - "name": "Alignment scores", - "description": "How closely tenants align with their baselines" + "description": "How closely tenants align with their baselines", + "name": "Alignment scores" }, { - "name": "Alignment details", - "description": "How a tenant's policies compare with a baseline" + "description": "How a tenant's policies compare with a baseline", + "name": "Alignment details" }, { - "name": "Assessments", - "description": "The assessments an API client can run" + "description": "The assessments an API client can run", + "name": "Assessments" }, { - "name": "Reports", - "description": "The reports an API client can run" + "description": "The reports an API client can run", + "name": "Reports" }, { - "name": "Audit events", - "description": "The activity log of an API client's client" + "description": "The activity log of an API client's client", + "name": "Audit events" } ] } diff --git a/module/InforcerCommunity.Format.ps1xml b/module/InforcerCommunity.Format.ps1xml index a4cb1fe..3590454 100644 --- a/module/InforcerCommunity.Format.ps1xml +++ b/module/InforcerCommunity.Format.ps1xml @@ -174,6 +174,38 @@ + + + InforcerCommunity.CreatedUser.Default + + InforcerCommunity.CreatedUser + + + + + + + + displayName + + + + userPrincipalName + + + + id + + + + TenantId + + + + + + + InforcerCommunity.User.Default diff --git a/module/InforcerCommunity.psd1 b/module/InforcerCommunity.psd1 index 8e1613e..be28dec 100644 --- a/module/InforcerCommunity.psd1 +++ b/module/InforcerCommunity.psd1 @@ -19,6 +19,8 @@ 'Get-InforcerAuditEvent' 'Get-InforcerSupportedEventType' 'Get-InforcerUser' + 'New-InforcerUser' + 'Set-InforcerUser' 'Get-InforcerGroup' 'Get-InforcerRole' 'Get-InforcerSecureScore' diff --git a/module/Private/ConvertTo-InforcerUserBody.ps1 b/module/Private/ConvertTo-InforcerUserBody.ps1 new file mode 100644 index 0000000..7605004 --- /dev/null +++ b/module/Private/ConvertTo-InforcerUserBody.ps1 @@ -0,0 +1,35 @@ +function ConvertTo-InforcerUserBody { + <# + .SYNOPSIS + Builds the userProfile part of a create or update body from bound parameters (Private helper). + .DESCRIPTION + Only parameters the caller passed are included, so an update leaves every other field as it is + (JSON Merge Patch). An empty string or an empty array becomes null, which clears the field. + Parameter names map to the API names by lowercasing the first letter. + #> + [CmdletBinding()] + [OutputType([System.Collections.Specialized.OrderedDictionary])] + param( + [Parameter(Mandatory = $true)] + [System.Collections.Generic.IDictionary[string, object]]$BoundParameters + ) + + $fields = 'AccountEnabled', 'DisplayName', 'MailNickname', 'UserPrincipalName', 'GivenName', 'Surname', + 'JobTitle', 'Department', 'OfficeLocation', 'StreetAddress', 'City', 'State', 'PostalCode', 'Country', + 'MobilePhone', 'UsageLocation', 'PreferredLanguage', 'CompanyName', 'EmployeeId', 'EmployeeType', + 'Mail', 'BusinessPhones', 'OtherMails', 'ManagerId', 'UserType' + + $body = [ordered]@{} + foreach ($name in $fields) { + if (-not $BoundParameters.ContainsKey($name)) { continue } + $value = $BoundParameters[$name] + if ($value -is [array]) { + $value = @($value | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) + if ($value.Count -eq 0) { $value = $null } + } elseif ($value -is [string] -and $value -eq '') { + $value = $null + } + $body[$name.Substring(0, 1).ToLowerInvariant() + $name.Substring(1)] = $value + } + $body +} diff --git a/module/Private/Get-InforcerAuthHeader.ps1 b/module/Private/Get-InforcerAuthHeader.ps1 index aba985d..25b0560 100644 --- a/module/Private/Get-InforcerAuthHeader.ps1 +++ b/module/Private/Get-InforcerAuthHeader.ps1 @@ -61,6 +61,18 @@ function Clear-InforcerRequestCredential { if ($message -is [System.Net.Http.HttpRequestMessage]) { $null = $message.Headers.Remove('Authorization') $null = $message.Headers.Remove('Inf-Api-Key') + # The body (a new user's password, for example) is disposed but its bytes stay in memory; + # zero them. ponytail: private .NET field, so a runtime without it keeps the bytes. + if ($message.Content -is [System.Net.Http.ByteArrayContent]) { + try { + $field = [System.Net.Http.ByteArrayContent].GetField('_content', [System.Reflection.BindingFlags]'NonPublic, Instance') + # No if-expression around GetValue: it would unroll the byte[] into a copy. + if ($field) { + $bytes = $field.GetValue($message.Content) + if ($bytes -is [byte[]]) { [array]::Clear($bytes, 0, $bytes.Length) } + } + } catch { Write-Debug "Could not clear the request body: $($_.Exception.Message)" } + } } } diff --git a/module/Private/Invoke-InforcerApiRequest.ps1 b/module/Private/Invoke-InforcerApiRequest.ps1 index b3b51d8..b9eb579 100644 --- a/module/Private/Invoke-InforcerApiRequest.ps1 +++ b/module/Private/Invoke-InforcerApiRequest.ps1 @@ -152,6 +152,14 @@ function Invoke-InforcerApiRequest { elseif ($problemDetail) { $problemDetail } else { $title } $fieldErrors = Format-InforcerProblemError -Errors $props['errors'].Value if ($fieldErrors) { $apiMessage = "$apiMessage ($fieldErrors)" } + # A partly applied operation lists each step, e.g. "profile: succeeded; manager: failed (reason)". + $steps = foreach ($r in @($props['results'].Value)) { + if ($r -isnot [System.Management.Automation.PSCustomObject]) { continue } + $step = "$((@($r.PSObject.Properties['step'].Value, $r.PSObject.Properties['id'].Value) -ne $null) -join ' '): $($r.PSObject.Properties['status'].Value)" + $why = $r.PSObject.Properties['title'].Value -as [string] + if ($why) { "$step ($why)" } else { $step } + } + if ($steps) { $apiMessage = "$apiMessage Steps: $(@($steps) -join '; ')" } $traceId = ($props['traceId'].Value -as [string]) } elseif ($isAppEnvelope -or $null -ne $props['errors']) { # App-layer envelope { success, message, errors[], errorCode } @@ -204,6 +212,9 @@ function Invoke-InforcerApiRequest { return } + # 204 No Content (an update): success with nothing to return. + if ($statusCode -eq 204) { return } + if ($null -eq $rawResponse -or ($rawResponse -is [string] -and [string]::IsNullOrWhiteSpace($rawResponse))) { Write-Error -Message 'API returned an empty response.' -ErrorId 'EmptyResponse' -Category InvalidData return diff --git a/module/Private/Wait-InforcerMailboxAction.ps1 b/module/Private/Wait-InforcerMailboxAction.ps1 new file mode 100644 index 0000000..b123182 --- /dev/null +++ b/module/Private/Wait-InforcerMailboxAction.ps1 @@ -0,0 +1,39 @@ +function Wait-InforcerMailboxAction { + # Polls a queued mailbox action until Exchange Online reports succeeded or failed. + # A failed action is written as an error; one still running at the deadline is a warning, not an error. + [CmdletBinding()] + param( + [Parameter(Mandatory)][string]$UserEndpoint, + [Parameter(Mandatory)][string]$ActionId, + [Parameter(Mandatory)][string]$Step, + [Parameter(Mandatory)][string]$UserId, + [int]$TimeoutSeconds = 300 + ) + $endpoint = "$UserEndpoint/mailbox/actions/$([System.Uri]::EscapeDataString($ActionId))" + $deadline = (Get-Date).AddSeconds($TimeoutSeconds) + $interval = 2 + $status = 'queued' + try { + while ($status -notin 'succeeded', 'failed') { + if ((Get-Date) -ge $deadline) { + Write-Warning "The request to $Step for user $UserId is still $status after $TimeoutSeconds seconds. Exchange Online carries on in the background (action id $ActionId)." + return + } + Write-Progress -Activity "Mailbox of user $UserId" -Status "${Step}: $status" + Start-Sleep -Seconds $interval + $interval = [Math]::Min($interval * 2, 15) + $actionErr = $null + $action = Invoke-InforcerApiRequest -Endpoint $endpoint -Method GET -ErrorVariable actionErr -ErrorAction SilentlyContinue + if ($actionErr) { + Write-Error -Message "The request to $Step was queued (action id $ActionId), but its progress could not be read. $($actionErr[-1].Exception.Message)" -ErrorId 'MailboxActionUnknown' -Category $actionErr[-1].CategoryInfo.Category + return + } + $status = $action.status + } + } finally { + Write-Progress -Activity "Mailbox of user $UserId" -Completed + } + if ($status -eq 'failed') { + Write-Error -Message "Exchange Online could not apply it: $($action.error.message) ($($action.error.code))." -ErrorId 'MailboxActionFailed' -Category InvalidResult + } +} diff --git a/module/Public/Get-InforcerTenant.ps1 b/module/Public/Get-InforcerTenant.ps1 index 14297de..0b577d2 100644 --- a/module/Public/Get-InforcerTenant.ps1 +++ b/module/Public/Get-InforcerTenant.ps1 @@ -15,11 +15,19 @@ for one tenant. ClientTenantId does not exist with client credentials; use MsTenantId or the tenant name. + + -IncludeSubscriptions adds subscriptions: the Microsoft products each tenant subscribes to, with + skuId, sku, name, capabilityStatus, appliesTo and units (enabled, consumed, available, suspended, + warning, lockedOut). One extra request per tenant (GET /tenants/{msTenantId}/subscriptions); + needs a login with an API client. .PARAMETER Format Output format. Raw = raw API response (default). .PARAMETER TenantId Optional. Return this tenant only. Accepts the Microsoft Tenant ID (GUID), the tenant name or DNS name, or (API-key login only) the numeric Client Tenant ID. +.PARAMETER IncludeSubscriptions + Adds the tenant's subscriptions (licences with their skuId and free seats). Pass a skuId to + Set-InforcerUser -AddLicense. API client login only. .PARAMETER OutputType PowerShellObject (default) or JsonObject. JSON output uses Depth 100. .EXAMPLE @@ -33,6 +41,9 @@ .EXAMPLE Get-InforcerTenant | Where-Object IsBaseline Lists baseline tenants. +.EXAMPLE + (Get-InforcerTenant -TenantId 'Contoso' -IncludeSubscriptions).subscriptions | Where-Object { $_.units.available -gt 0 } + Lists the licences of Contoso that still have a free seat. .EXAMPLE Get-InforcerTenant -Format Raw -OutputType JsonObject .OUTPUTS @@ -54,6 +65,9 @@ param( [Alias('ClientTenantId', 'MsTenantId')] [object]$TenantId, + [Parameter(Mandatory = $false)] + [switch]$IncludeSubscriptions, + [Parameter(Mandatory = $false)] [ValidateSet('PowerShellObject', 'JsonObject')] [string]$OutputType = 'PowerShellObject' @@ -71,6 +85,10 @@ process { Write-Verbose 'Retrieving tenant information...' $isV1 = $script:InforcerSession.ApiVersion -eq 'v1' + if ($IncludeSubscriptions -and -not $isV1) { + Write-Error -Message 'Subscriptions need a login with an API client (Connect-Inforcer -ClientId -ClientSecret). The API-key (beta) API does not return them.' -ErrorId 'RequiresApiClient' -Category InvalidOperation + return + } # Get-InforcerTenantList objects are a shared cache: filter and copy them, never modify them. if ($null -ne $TenantId) { @@ -117,6 +135,16 @@ process { if ($listErr -or ($tenantData.Count -eq 0 -and -not ($isV1 -and $OutputType -eq 'JsonObject'))) { return } } + if ($IncludeSubscriptions) { + $tenantData = @(foreach ($t in $tenantData) { + $copy = [ordered]@{} + foreach ($p in $t.PSObject.Properties) { $copy[$p.Name] = $p.Value } + $subs = Invoke-InforcerApiRequest -Endpoint "/tenants/$($t.msTenantId)/subscriptions" -Method GET -PreserveStructure + if ($null -ne $subs) { $copy['subscriptions'] = @($subs.subscriptions) } + [PSCustomObject]$copy + }) + } + if ($OutputType -eq 'JsonObject') { if ($isV1) { return ConvertTo-Json -InputObject $tenantData -Depth 100 } return ($tenantData | ConvertTo-Json -Depth 100) diff --git a/module/Public/Get-InforcerUser.ps1 b/module/Public/Get-InforcerUser.ps1 index 3ac036c..2151628 100644 --- a/module/Public/Get-InforcerUser.ps1 +++ b/module/Public/Get-InforcerUser.ps1 @@ -5,6 +5,7 @@ function Get-InforcerUser { Required API scope(s): Tenants.Users.Read + Tenants.Read (only when -TenantId is a GUID or tenant name) (API key); User & Group Management + Tenants (only for a tenant name) permission (API client, unconfirmed). + -IncludeAuthenticationMethods and -IncludeMailbox need a login with an API client. .DESCRIPTION Gets a list of users or a single user by ID from the Inforcer API. Works with both login types (API key and client credentials). @@ -26,6 +27,19 @@ function Get-InforcerUser { .PARAMETER UserId The user ID (GUID) to retrieve full details for. Only available in the ById parameter set. + .PARAMETER IncludeAuthenticationMethods + Adds authenticationMethods to the user: the sign-in methods they have registered, such as their + password, phones, Microsoft Authenticator and passkeys (one extra request). Passwords and Temporary + Access Pass codes are never returned. Only with -UserId and a login with an API client + (Connect-Inforcer -ClientId -ClientSecret); an API-key login gets the error RequiresApiClient. + + .PARAMETER IncludeMailbox + Adds mailbox to the user: the Exchange Online mailbox as it is now (type, size, archive, litigation + hold, email addresses, hiddenFromAddressList, forwarding, mailApps), with autoReply, permissions (and + unreadPermissions, the kinds Exchange could not read just now), calendarAccess, mailGroups + (distribution lists and mail-enabled security groups) and inboxRules. Six extra requests. mailbox is null when the user has + no mailbox. Only with -UserId and a login with an API client. Change these with Set-InforcerUser. + .PARAMETER OutputType Output type: 'PowerShellObject' (default) or 'JsonObject'. Depth 100; the v1 list is always a JSON array. Piped tenants: each user carries TenantId and JsonObject returns one array for all tenants. @@ -45,6 +59,17 @@ function Get-InforcerUser { Gets full detail for a specific user. + .EXAMPLE + (Get-InforcerUser -TenantId 'Contoso' -UserId "00000000-0000-0000-0000-000000000005" -IncludeAuthenticationMethods).authenticationMethods + + Lists the sign-in methods the user has registered, such as password, phone and passkey. + + .EXAMPLE + $mailbox = (Get-InforcerUser -TenantId 'Contoso' -UserId "00000000-0000-0000-0000-000000000005" -IncludeMailbox).mailbox + $mailbox.forwarding; $mailbox.inboxRules | Where-Object forwardsExternally + + Shows where the user's mail is forwarded and which inbox rules send mail outside the tenant. + .EXAMPLE Get-InforcerTenant -TenantId 'Contoso' | Get-InforcerUser @@ -86,6 +111,12 @@ function Get-InforcerUser { [Parameter(Mandatory, ParameterSetName = 'ById')] [string]$UserId, + [Parameter(ParameterSetName = 'ById')] + [switch]$IncludeAuthenticationMethods, + + [Parameter(ParameterSetName = 'ById')] + [switch]$IncludeMailbox, + [Parameter(ParameterSetName = 'List')] [Parameter(ParameterSetName = 'ById')] [ValidateSet('PowerShellObject', 'JsonObject')] @@ -100,6 +131,11 @@ function Get-InforcerUser { return } + if (($IncludeAuthenticationMethods -or $IncludeMailbox) -and $script:InforcerSession.ApiVersion -ne 'v1') { + Write-Error -Message 'Authentication methods and mailboxes need a login with an API client (Connect-Inforcer -ClientId -ClientSecret). The API-key (beta) API does not return them.' -ErrorId 'RequiresApiClient' -Category InvalidOperation + return + } + try { $resolvedTenantId = Resolve-InforcerTenantId -TenantId $TenantId } catch { @@ -133,6 +169,36 @@ function Get-InforcerUser { return } + if ($IncludeAuthenticationMethods) { + $methods = Invoke-InforcerApiRequest -Endpoint "$endpoint/authenticationMethods" -Method GET -PreserveStructure + if ($null -ne $methods) { + $response.PSObject.Properties.Remove('authenticationMethods') + $response.PSObject.Properties.Add([System.Management.Automation.PSNoteProperty]::new('authenticationMethods', @($methods.authenticationMethods))) + } + } + + if ($IncludeMailbox) { + $mailboxErr = $null + $mailbox = Invoke-InforcerApiRequest -Endpoint "$endpoint/mailbox" -Method GET -PreserveStructure -ErrorVariable mailboxErr -ErrorAction SilentlyContinue + # 404: the user has no mailbox, so mailbox is null; any other failure is reported and leaves mailbox out. + $noMailbox = $mailboxErr -and $mailboxErr[-1].FullyQualifiedErrorId -like 'ApiRequestFailed_404*' + if ($mailboxErr -and -not $noMailbox) { Write-Error -ErrorRecord $mailboxErr[-1] } + if ($null -ne $mailbox) { + foreach ($part in 'autoReply', 'permissions', 'calendarAccess', 'mailGroups', 'inboxRules') { + $result = Invoke-InforcerApiRequest -Endpoint "$endpoint/mailbox/$part" -Method GET -PreserveStructure + if ($null -eq $result) { continue } + # Plain assignments: an if-expression would unroll an empty list to null. + $value = $result + if ($part -ne 'autoReply') { $value = @($result.$part) } + $mailbox | Add-Member -NotePropertyName $part -NotePropertyValue $value -Force + if ($part -eq 'permissions') { $mailbox | Add-Member -NotePropertyName unreadPermissions -NotePropertyValue @($result.unreadPermissions) -Force } + } + } + if (-not $mailboxErr -or $noMailbox) { + $response | Add-Member -NotePropertyName mailbox -NotePropertyValue $mailbox -Force + } + } + & $addTenantId $response if ($OutputType -eq 'JsonObject') { if ($piped) { $pipedJson.Add($response); return } diff --git a/module/Public/New-InforcerUser.ps1 b/module/Public/New-InforcerUser.ps1 new file mode 100644 index 0000000..ccf4622 --- /dev/null +++ b/module/Public/New-InforcerUser.ps1 @@ -0,0 +1,252 @@ +function New-InforcerUser { + <# + .SYNOPSIS + Creates a Microsoft Entra user in a tenant. + + Required API scope(s): none; the API-key (beta) API cannot create users. + Required permission: User & Group Management (API client, unconfirmed which grant). + + .DESCRIPTION + Creates a user with POST /tenants/{msTenantId}/users. Needs a login with an API client + (Connect-Inforcer -ClientId -ClientSecret); an API-key login gets the error RequiresApiClient. + + The user can sign in by default (-AccountEnabled $true) and must change the password at the + first sign-in (-ForceChangePasswordNextSignIn $true). -MailNickname defaults to the part of + -UserPrincipalName before the @. The password must meet the tenant's password policy. + + Returns the new user's id with the tenant, display name and user principal name, so the result + can be piped to Set-InforcerUser. Get-InforcerUser can take up to about five minutes to show the new user, because the API caches users. + + .PARAMETER TenantId + The tenant's Microsoft tenant GUID or tenant name. Supports pipeline input by property name. + + .PARAMETER DisplayName + The name shown for the user. + + .PARAMETER UserPrincipalName + The sign-in name, such as jo.bloggs@contoso.com. The domain must be verified in the tenant. + + .PARAMETER Password + The initial password as a SecureString. It must meet the tenant's password policy. + + .PARAMETER MailNickname + The mail alias. Defaults to the part of -UserPrincipalName before the @. + + .PARAMETER ForceChangePasswordNextSignIn + Whether the user must change the password at the first sign-in. Default: $true. + + .PARAMETER AccountEnabled + Whether the user can sign in. Default: $true. + + .PARAMETER GivenName + First name. + + .PARAMETER Surname + Last name. + + .PARAMETER JobTitle + Job title. + + .PARAMETER Department + Department. + + .PARAMETER OfficeLocation + Office location. + + .PARAMETER StreetAddress + Street address. + + .PARAMETER City + City. + + .PARAMETER State + State or province. + + .PARAMETER PostalCode + Postal code. + + .PARAMETER Country + Country or region. + + .PARAMETER MobilePhone + Mobile phone number. + + .PARAMETER UsageLocation + Two-letter country code (ISO 3166) where the user's licences are used, such as GB. Needed before + licences can be assigned. + + .PARAMETER PreferredLanguage + Preferred language, such as en-GB. + + .PARAMETER CompanyName + Company name. + + .PARAMETER EmployeeId + Employee id (at most 16 characters). + + .PARAMETER EmployeeType + Employee type, such as Employee or Contractor. + + .PARAMETER Mail + Email address. + + .PARAMETER BusinessPhones + Business phone number. Microsoft Entra allows one. + + .PARAMETER OtherMails + Other email addresses. + + .PARAMETER ManagerId + The Microsoft Entra object id of the user's manager. + + .PARAMETER UserType + Member (the default when left out) or Guest. + + .PARAMETER OutputType + Output type: 'PowerShellObject' (default) or 'JsonObject' (JSON string, depth 100). + Piped tenants with JsonObject return one array for all of them. + + .EXAMPLE + $password = Read-Host -AsSecureString -Prompt 'Initial password' + New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password + + Creates Jo Bloggs in the tenant Contoso. Jo must change the password at the first sign-in. + + .EXAMPLE + New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password -GivenName 'Jo' -Surname 'Bloggs' -Department 'Sales' -UsageLocation 'GB' -AccountEnabled $false + + Creates the user with profile details, but blocked from signing in until enabled with Set-InforcerUser. + + .EXAMPLE + New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password -WhatIf + + Shows what would be created without creating it. + + .EXAMPLE + New-InforcerUser -TenantId 'Contoso' -DisplayName 'Jo Bloggs' -UserPrincipalName 'jo.bloggs@contoso.com' -Password $password -OutputType JsonObject + + Returns the new user's id, tenant, display name and user principal name as a JSON string. + + .OUTPUTS + PSObject or String (when -OutputType JsonObject) + + .LINK + https://github.com/royklo/InforcerCommunity/blob/main/docs/CMDLET-REFERENCE.md#new-inforceruser + + .LINK + Set-InforcerUser + + .LINK + Get-InforcerUser + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] + [OutputType([PSObject], [string])] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Alias('ClientTenantId', 'MsTenantId')] + [object]$TenantId, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$DisplayName, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$UserPrincipalName, + + [Parameter(Mandatory)] + [System.Security.SecureString]$Password, + + [ValidateNotNullOrEmpty()] + [string]$MailNickname, + + [bool]$ForceChangePasswordNextSignIn = $true, + + [bool]$AccountEnabled = $true, + + [string]$GivenName, + [string]$Surname, + [string]$JobTitle, + [string]$Department, + [string]$OfficeLocation, + [string]$StreetAddress, + [string]$City, + [string]$State, + [string]$PostalCode, + [string]$Country, + [string]$MobilePhone, + [string]$UsageLocation, + [string]$PreferredLanguage, + [string]$CompanyName, + [string]$EmployeeId, + [string]$EmployeeType, + [string]$Mail, + [string[]]$BusinessPhones, + [string[]]$OtherMails, + [string]$ManagerId, + + [ValidateSet('Member', 'Guest')] + [string]$UserType, + + [ValidateSet('PowerShellObject', 'JsonObject')] + [string]$OutputType = 'PowerShellObject' + ) + + begin { $pipedJson = [System.Collections.Generic.List[object]]::new() } + + process { + if (-not (Test-InforcerSession)) { + Write-Error -Message 'Not connected to Inforcer. Use Connect-Inforcer first.' -ErrorId 'NotConnected' -Category ConnectionError + return + } + if ($script:InforcerSession.ApiVersion -ne 'v1') { + Write-Error -Message 'Creating users needs a login with an API client (Connect-Inforcer -ClientId -ClientSecret). The API-key (beta) API cannot create users.' -ErrorId 'RequiresApiClient' -Category InvalidOperation + return + } + + try { + $resolvedTenantId = Resolve-InforcerTenantId -TenantId $TenantId + } catch { + Write-Error -Message $_.Exception.Message -ErrorId 'InvalidTenantId' -Category InvalidArgument + return + } + + if (-not $PSCmdlet.ShouldProcess("$UserPrincipalName in tenant $resolvedTenantId", 'Create user')) { return } + + $body = ConvertTo-InforcerUserBody -BoundParameters $PSBoundParameters + $body['accountEnabled'] = $AccountEnabled + if (-not $body['mailNickname']) { $body['mailNickname'] = ($UserPrincipalName -split '@')[0] } + $body['passwordProfile'] = [ordered]@{ + password = ConvertFrom-InforcerSecureString -SecureString $Password + forceChangePasswordNextSignIn = $ForceChangePasswordNextSignIn + } + try { + $json = $body | ConvertTo-Json -Depth 100 -Compress + $body = $null + $response = Invoke-InforcerApiRequest -Endpoint "/tenants/$resolvedTenantId/users" -Method POST -Body $json -PreserveStructure + } finally { + $json = $null + $body = $null + } + if ($null -eq $response) { return } + + foreach ($p in ([ordered]@{ TenantId = $resolvedTenantId; displayName = $DisplayName; userPrincipalName = $UserPrincipalName }).GetEnumerator()) { + if (-not $response.PSObject.Properties[$p.Key]) { + $response.PSObject.Properties.Add([System.Management.Automation.PSNoteProperty]::new($p.Key, $p.Value)) + } + } + + if ($OutputType -eq 'JsonObject') { + if ($PSCmdlet.MyInvocation.ExpectingInput) { $pipedJson.Add($response); return } + return $response | ConvertTo-Json -Depth 100 + } + $response.PSObject.TypeNames.Insert(0, 'InforcerCommunity.CreatedUser') + $response + } + + end { + if ($PSCmdlet.MyInvocation.ExpectingInput -and $OutputType -eq 'JsonObject' -and $pipedJson.Count -gt 0) { + ConvertTo-Json -InputObject @($pipedJson) -Depth 100 + } + } +} diff --git a/module/Public/Set-InforcerUser.ps1 b/module/Public/Set-InforcerUser.ps1 new file mode 100644 index 0000000..ea1e85c --- /dev/null +++ b/module/Public/Set-InforcerUser.ps1 @@ -0,0 +1,710 @@ +function Set-InforcerUser { + <# + .SYNOPSIS + Updates a Microsoft Entra user's profile, manager, sign-in, licences or group memberships, changes their Exchange Online mailbox (shared or user, online archive, address lists, email addresses, automatic replies, forwarding, permissions, calendar sharing, mail groups, inbox rules, mail apps), resets their password, removes sign-in methods (or all of them, to reset MFA), issues a Temporary Access Pass or signs them out everywhere. + + Required API scope(s): none; the API-key (beta) API cannot update users. + Required permission: User & Group Management (API client, unconfirmed which grant). + + .DESCRIPTION + Updates a user with PATCH /tenants/{msTenantId}/users/{userId}. Needs a login with an API client + (Connect-Inforcer -ClientId -ClientSecret); an API-key login gets the error RequiresApiClient. + + Only the parameters you pass are changed; everything else stays as it is. Pass an empty string + ('') or $null to clear a field, such as -JobTitle '' or -ManagerId '' to remove the manager. + DisplayName, MailNickname, UserPrincipalName, Mail and UserType cannot be cleared. + + -AddLicense and -RemoveLicense change the user's licences in one request + (POST .../users/{userId}/assignLicenses); if one licence is refused, nothing changes. + -AddGroup and -RemoveGroup change the user's Microsoft Entra group memberships + (POST .../users/{userId}/groups). Adding runs first and removing only after every add succeeded, so a + user moved between groups is never left in neither. A group the user is already in, or not in, counts + as done. + Mailbox changes (-MailboxType, -EnableArchive, -HiddenFromAddressLists, -AddEmailAddress, -PrimaryEmailAddress, + -RemoveEmailAddress, -AutoReply, -ForwardTo, -RemoveForwarding, -GrantMailboxPermission, + -RemoveMailboxPermission, -GrantCalendarAccess, -RemoveCalendarAccess, -AddMailGroup, -RemoveMailGroup, + -RemoveInboxRule, -RemoveAllInboxRules, -AllowMailApp, -BlockMailApp) + each go to .../users/{userId}/mailbox/... and are queued in Exchange Online, which applies one change + to a mailbox at a time, about a minute each. The cmdlet waits for each to succeed or fail (at most + 5 minutes per change, then it warns that Exchange carries on) before the next step. Read the + mailbox with Get-InforcerUser -IncludeMailbox. A Global Administrator's mailbox is refused. + -Password sets a new password (POST /tenants/{msTenantId}/users/{userId}/password); the user must + change it when they next sign in unless you pass -ForceChangePasswordNextSignIn $false. + -RemoveAuthenticationMethod deletes registered sign-in methods, such as a phone or Microsoft + Authenticator (DELETE .../users/{userId}/authenticationMethods/{methodId}); take the ids from + Get-InforcerUser -IncludeAuthenticationMethods, where only methods with deletable true can be removed. + -ResetMfa deletes every method with deletable true in one request (DELETE .../users/{userId}/mfa), + in the order Microsoft Entra needs, so the user must register MFA again; the password is kept. + -TemporaryAccessPass creates a Temporary Access Pass (POST .../authenticationMethods/temporaryAccessPasses) + and returns it; the pass cannot be read again, and it replaces a pass the user already has. + -RevokeSessions signs the user out of every session (POST .../users/{userId}/revokeSessions); + access tokens already issued stay valid until they expire, typically within 90 minutes. + In one call the steps run in this order: profile update, licences (when -AddLicense is given), adding + to groups, removing from groups, mailbox + type, online archive, address lists, adding email addresses, primary email address, removing email addresses, + automatic replies, forwarding, granting and removing mailbox permissions, sharing and unsharing the + calendar, adding to and removing from mail groups, removing inbox rules, mail apps, licences (when + only -RemoveLicense is given, so a mailbox is converted to shared before its licence goes), password reset, removing sign-in methods, MFA reset, + Temporary Access Pass, sign-out. When a step fails, the later steps + are skipped and the error says which steps were already done. + + -AccountEnabled $false blocks sign-in, but existing sessions last until their tokens expire; + add -RevokeSessions to end them. + Get-InforcerUser can show the old values for up to about five minutes, because the API caches users. Returns nothing, except the pass with -TemporaryAccessPass. + + When the manager could not be changed but the other changes were saved, the error lists + each step and whether it was applied. + + .PARAMETER TenantId + The tenant's Microsoft tenant GUID or tenant name. Supports pipeline input by property name. + + .PARAMETER UserId + The user's Microsoft Entra object id. Supports pipeline input by property name (also from id), + so users from Get-InforcerUser or New-InforcerUser can be piped in. + + .PARAMETER AccountEnabled + Whether the user can sign in. + + .PARAMETER DisplayName + The name shown for the user. Cannot be cleared. + + .PARAMETER MailNickname + The mail alias. Cannot be cleared. + + .PARAMETER UserPrincipalName + The sign-in name, such as jo.bloggs@contoso.com. Cannot be cleared. + + .PARAMETER GivenName + First name. '' clears it. + + .PARAMETER Surname + Last name. '' clears it. + + .PARAMETER JobTitle + Job title. '' clears it. + + .PARAMETER Department + Department. '' clears it. + + .PARAMETER OfficeLocation + Office location. '' clears it. + + .PARAMETER StreetAddress + Street address. '' clears it. + + .PARAMETER City + City. '' clears it. + + .PARAMETER State + State or province. '' clears it. + + .PARAMETER PostalCode + Postal code. '' clears it. + + .PARAMETER Country + Country or region. '' clears it. + + .PARAMETER MobilePhone + Mobile phone number. '' clears it. + + .PARAMETER UsageLocation + Two-letter country code (ISO 3166) where the user's licences are used, such as GB. '' clears it. + + .PARAMETER PreferredLanguage + Preferred language, such as en-GB. '' clears it. + + .PARAMETER CompanyName + Company name. '' clears it. + + .PARAMETER EmployeeId + Employee id (at most 16 characters). '' clears it. + + .PARAMETER EmployeeType + Employee type, such as Employee or Contractor. '' clears it. + + .PARAMETER Mail + Email address. Cannot be cleared. + + .PARAMETER BusinessPhones + Business phone number. Microsoft Entra allows one. @() clears it. + + .PARAMETER OtherMails + Other email addresses. Replaces the whole list; @() clears it. + + .PARAMETER ManagerId + The Microsoft Entra object id of the user's manager. '' removes the manager. + + .PARAMETER UserType + Member or Guest. Cannot be cleared. + + .PARAMETER AddLicense + The skuId of one or more licences to give the user, from Get-InforcerTenant -IncludeSubscriptions + (which also shows free seats) or assignedLicenses of Get-InforcerUser -UserId. + A licence with no free seat, not subscribed to, or conflicting with the user's other licences is + refused. The user needs a usage location (-UsageLocation, set in the same call if needed). + + .PARAMETER RemoveLicense + The skuId of one or more licences to take from the user. A licence the user gets through a group + is refused; one the user does not have is ignored. + + .PARAMETER AddGroup + The object id of one or more Microsoft Entra groups (at most 20) to add the user to. Role-assignable + groups are refused. + + .PARAMETER RemoveGroup + The object id of one or more Microsoft Entra groups (at most 20) to remove the user from. Runs only + after -AddGroup succeeded. Role-assignable groups are refused. + + .PARAMETER HiddenFromAddressLists + $true hides the user's mailbox from the address lists (the global address list in Outlook), $false + shows it again. The user needs a mailbox; a Global Administrator's mailbox is refused. + + .PARAMETER MailboxType + User or Shared. Converts the mailbox to a shared mailbox (for a leaver, before the licence is + removed) or back to a user mailbox. + + .PARAMETER EnableArchive + Turns on the mailbox's online archive. It cannot be turned off here; one already on is left as it is. + Mail moves into the archive under the tenant's retention policy, not straight away. Refused for a + user synced from on-premises Active Directory. + + .PARAMETER AutoReply + The automatic replies, as a hashtable or the autoReply object Get-InforcerUser -IncludeMailbox + returns (null values and simplified are left out). status is always needed: disabled, alwaysEnabled + or scheduled. alwaysEnabled and scheduled also need internalReplyMessage and externalAudience (none, + contactsOnly or all), externalReplyMessage unless externalAudience is none, and scheduled needs + scheduledStartDateTime and scheduledEndDateTime. Exchange sets the replies as a whole, so a property + left out is not kept. Messages keep only bold, italic, underline and text size. + + .PARAMETER ForwardTo + Forwards the user's mail to another user in the tenant (their Microsoft Entra object id) or to an + address on one of the tenant's verified domains. Replaces any earlier forwarding. + + .PARAMETER KeepForwardedCopy + Keeps a copy of forwarded mail in the mailbox. Only with -ForwardTo. + + .PARAMETER RemoveForwarding + Stops forwarding the user's mail. + + .PARAMETER GrantMailboxPermission + One or more permissions to give another user on this mailbox, each with permission (fullAccess, + sendAs or sendOnBehalf) and trusteeId (the other user's object id), and for fullAccess optionally + automapping ($true adds the mailbox to their Outlook). + + .PARAMETER RemoveMailboxPermission + One or more permissions to take away, each with permission and trusteeId, such as entries of + mailbox.permissions from Get-InforcerUser -IncludeMailbox. An inherited permission cannot be removed. + + .PARAMETER GrantCalendarAccess + One or more users to share the calendar with, each with trusteeId (a member of the tenant, not a + guest) and role: reviewer (sees events), editor (also creates, changes and deletes them) or delegate + (an editor who also receives meeting requests). A user who already has access gets the new role. + + .PARAMETER RemoveCalendarAccess + The object id of one or more users whose access to the calendar is taken away, whatever their + role, such as trusteeId of mailbox.calendarAccess from Get-InforcerUser -IncludeMailbox. + + .PARAMETER AddMailGroup + The object id of one or more distribution lists or mail-enabled security groups to add the user to. + Microsoft 365 groups and groups synced from on-premises Active Directory are refused. + + .PARAMETER RemoveMailGroup + The object id of one or more distribution lists or mail-enabled security groups to remove the user from. + + .PARAMETER AddEmailAddress + One or more email addresses to add to the mailbox, on domains verified in the tenant. Refused for + a user synced from on-premises Active Directory. + + .PARAMETER PrimaryEmailAddress + Adds this address if needed and makes it the mailbox's main address. Runs after -AddEmailAddress + and before -RemoveEmailAddress, so the old main address can be removed in the same call. + + .PARAMETER RemoveEmailAddress + One or more email addresses to remove from the mailbox. The main address and the sign-in address + are refused. + + .PARAMETER RemoveInboxRule + The id of one or more inbox rules to remove, from mailbox.inboxRules of Get-InforcerUser + -IncludeMailbox. A rule with deletable false cannot be removed. + + .PARAMETER RemoveAllInboxRules + Removes every inbox rule Exchange can remove; rules such as the junk filter are kept. + + .PARAMETER AllowMailApp + Mail apps the mailbox may connect with: OutlookWeb (also the new Outlook for Windows), + OutlookDesktop (classic Outlook for Windows), OutlookMac (the new Outlook for Mac), + ExchangeWebServices, Imap, Pop, OutlookApp (iOS and Android) and OtherMailApps (Exchange + ActiveSync, such as iPhone Mail). A tenant-wide policy can still block an app. Apps not named keep + their setting; see mailbox.mailApps from Get-InforcerUser -IncludeMailbox. + + .PARAMETER BlockMailApp + Mail apps the mailbox may no longer connect with, with the names of -AllowMailApp. Allowing and + blocking happen in one change. + + .PARAMETER Password + A new password as a SecureString. It must meet the tenant's password policy. + inforcer does not store or log it. + + .PARAMETER ForceChangePasswordNextSignIn + Whether the user must change the new password when they next sign in. Default $true. + Only together with -Password. + + .PARAMETER RemoveAuthenticationMethod + The id of one or more registered sign-in methods to delete, from the authenticationMethods that + Get-InforcerUser -IncludeAuthenticationMethods returns. Only methods with deletable true can be + removed; Microsoft Entra can also refuse one, such as the default method while another phone remains. + + .PARAMETER ResetMfa + Deletes every sign-in method the user registered that can be deleted (phones, Microsoft + Authenticator, passkeys, ...), so they must register MFA again at the next sign-in. The password is kept. + + .PARAMETER TemporaryAccessPass + Creates a Temporary Access Pass and returns it as an object with temporaryAccessPass, id, + startDateTime, lifetimeInMinutes, usableOnce and userId. The pass is shown only this once. + It runs after -ResetMfa, which would otherwise delete it. + + .PARAMETER TemporaryAccessPassLifetime + How long the pass lasts, in minutes (10 to 43200, and within the tenant's policy). Without it the + tenant's default applies. Only with -TemporaryAccessPass. + + .PARAMETER TemporaryAccessPassUsableOnce + Whether the pass can be used only once. Without it the tenant's policy decides. Only with + -TemporaryAccessPass. + + .PARAMETER RevokeSessions + Signs the user out of every session by revoking their refresh tokens and session cookies. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -Department 'Sales' -JobTitle 'Account Manager' + + Changes the department and job title. Every other field stays as it is. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false + + Blocks the user from signing in. + + .EXAMPLE + Get-InforcerUser -TenantId 'Contoso' -Search 'Adele' | Set-InforcerUser -TenantId 'Contoso' -ManagerId '' + + Removes the manager of every user matching "Adele". + + .EXAMPLE + $password = Read-Host -AsSecureString -Prompt 'New password' + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -Password $password -RevokeSessions + + Resets the password (the user must change it at the next sign-in) and signs the user out everywhere. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false -RevokeSessions + + Blocks sign-in and ends the user's existing sessions. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -Password $password -ResetMfa -RevokeSessions + + Locks out a compromised account: new password, every removable sign-in method deleted, signed out everywhere. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -ResetMfa -TemporaryAccessPass -TemporaryAccessPassLifetime 60 -TemporaryAccessPassUsableOnce $true + + Resets MFA and returns a one-time pass, valid for an hour, so the user can register new sign-in methods. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -UsageLocation 'GB' -AddLicense '00000000-0000-0000-0000-0000000000b1' + + Sets the usage location, then gives the user a licence. + + .EXAMPLE + $user = Get-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -IncludeAuthenticationMethods + $lost = @($user.authenticationMethods | Where-Object { $_.phoneNumber -eq '+44 7700 900000' }).id + Set-InforcerUser -TenantId 'Contoso' -UserId $user.id -RemoveAuthenticationMethod $lost + + Removes one lost phone and keeps the user's other sign-in methods. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false -HiddenFromAddressLists $true -RevokeSessions + + Offboards a leaver: blocks sign-in, hides the mailbox from the address book and ends every session. + + .EXAMPLE + $reply = @{ status = 'alwaysEnabled'; externalAudience = 'all'; internalReplyMessage = 'Jo has left Contoso. Please contact sales@contoso.com.'; externalReplyMessage = 'Jo has left Contoso. Please contact sales@contoso.com.' } + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AccountEnabled $false -MailboxType Shared -AutoReply $reply -GrantMailboxPermission @{ permission = 'fullAccess'; trusteeId = '00000000-0000-0000-0000-000000000006' } -RemoveLicense '00000000-0000-0000-0000-0000000000b1' -RevokeSessions + + Offboards a leaver and keeps their mail: blocks sign-in, converts the mailbox to shared, sets an + automatic reply, gives the manager full access, then removes the licence and ends every session. + + .EXAMPLE + $mailbox = (Get-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -IncludeMailbox).mailbox + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -RemoveForwarding -RemoveInboxRule @($mailbox.inboxRules | Where-Object forwardsExternally).id + + Stops a compromised mailbox from sending mail out: removes its forwarding and every inbox rule that forwards outside the tenant. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -BlockMailApp Imap, Pop -GrantCalendarAccess @{ trusteeId = '00000000-0000-0000-0000-000000000006'; role = 'delegate' } + + Blocks IMAP and POP for the mailbox and makes another user a delegate of its calendar. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -AddGroup '00000000-0000-0000-0000-0000000000c2' -RemoveGroup '00000000-0000-0000-0000-0000000000c1' + + Moves the user to another group: adds them to the new group, then removes them from the old one. + + .EXAMPLE + Set-InforcerUser -TenantId 'Contoso' -UserId '00000000-0000-0000-0000-000000000005' -UsageLocation 'GB' -WhatIf + + Shows what would change without changing it. + + .OUTPUTS + None, or with -TemporaryAccessPass the created pass (PSCustomObject). + + .LINK + https://github.com/royklo/InforcerCommunity/blob/main/docs/CMDLET-REFERENCE.md#set-inforceruser + + .LINK + New-InforcerUser + + .LINK + Get-InforcerUser + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] + [OutputType([void], [pscustomobject])] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Alias('ClientTenantId', 'MsTenantId')] + [object]$TenantId, + + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Alias('Id')] + [ValidateNotNullOrEmpty()] + [string]$UserId, + + [bool]$AccountEnabled, + + [ValidateNotNullOrEmpty()] + [string]$DisplayName, + + [ValidateNotNullOrEmpty()] + [string]$MailNickname, + + [ValidateNotNullOrEmpty()] + [string]$UserPrincipalName, + + [string]$GivenName, + [string]$Surname, + [string]$JobTitle, + [string]$Department, + [string]$OfficeLocation, + [string]$StreetAddress, + [string]$City, + [string]$State, + [string]$PostalCode, + [string]$Country, + [string]$MobilePhone, + [string]$UsageLocation, + [string]$PreferredLanguage, + [string]$CompanyName, + [string]$EmployeeId, + [string]$EmployeeType, + + [ValidateNotNullOrEmpty()] + [string]$Mail, + + [AllowNull()] + [AllowEmptyCollection()] + [string[]]$BusinessPhones, + + [AllowNull()] + [AllowEmptyCollection()] + [string[]]$OtherMails, + + [string]$ManagerId, + + [ValidateSet('Member', 'Guest')] + [string]$UserType, + + [ValidateNotNullOrEmpty()] + [guid[]]$AddLicense, + + [ValidateNotNullOrEmpty()] + [guid[]]$RemoveLicense, + + [ValidateCount(1, 20)] + [guid[]]$AddGroup, + + [ValidateCount(1, 20)] + [guid[]]$RemoveGroup, + + [bool]$HiddenFromAddressLists, + + [ValidateSet('User', 'Shared')] + [string]$MailboxType, + + [switch]$EnableArchive, + + [ValidateNotNull()] + [object]$AutoReply, + + [ValidateNotNullOrEmpty()] + [string]$ForwardTo, + + [switch]$KeepForwardedCopy, + + [switch]$RemoveForwarding, + + [ValidateNotNullOrEmpty()] + [object[]]$GrantMailboxPermission, + + [ValidateNotNullOrEmpty()] + [object[]]$RemoveMailboxPermission, + + [ValidateNotNullOrEmpty()] + [object[]]$GrantCalendarAccess, + + [ValidateNotNullOrEmpty()] + [guid[]]$RemoveCalendarAccess, + + [ValidateNotNullOrEmpty()] + [guid[]]$AddMailGroup, + + [ValidateNotNullOrEmpty()] + [guid[]]$RemoveMailGroup, + + [ValidateNotNullOrEmpty()] + [string[]]$AddEmailAddress, + + [ValidateNotNullOrEmpty()] + [string]$PrimaryEmailAddress, + + [ValidateNotNullOrEmpty()] + [string[]]$RemoveEmailAddress, + + [ValidateNotNullOrEmpty()] + [string[]]$RemoveInboxRule, + + [switch]$RemoveAllInboxRules, + + [ValidateSet('OutlookWeb', 'OutlookDesktop', 'OutlookMac', 'ExchangeWebServices', 'Imap', 'Pop', 'OutlookApp', 'OtherMailApps')] + [string[]]$AllowMailApp, + + [ValidateSet('OutlookWeb', 'OutlookDesktop', 'OutlookMac', 'ExchangeWebServices', 'Imap', 'Pop', 'OutlookApp', 'OtherMailApps')] + [string[]]$BlockMailApp, + + [System.Security.SecureString]$Password, + + [bool]$ForceChangePasswordNextSignIn = $true, + + [ValidateNotNullOrEmpty()] + [string[]]$RemoveAuthenticationMethod, + + [switch]$ResetMfa, + + [switch]$TemporaryAccessPass, + + [ValidateRange(10, 43200)] + [int]$TemporaryAccessPassLifetime, + + [bool]$TemporaryAccessPassUsableOnce, + + [switch]$RevokeSessions + ) + + process { + if (-not (Test-InforcerSession)) { + Write-Error -Message 'Not connected to Inforcer. Use Connect-Inforcer first.' -ErrorId 'NotConnected' -Category ConnectionError + return + } + if ($script:InforcerSession.ApiVersion -ne 'v1') { + Write-Error -Message 'Updating users needs a login with an API client (Connect-Inforcer -ClientId -ClientSecret). The API-key (beta) API cannot update users.' -ErrorId 'RequiresApiClient' -Category InvalidOperation + return + } + + if ($PSBoundParameters.ContainsKey('ForceChangePasswordNextSignIn') -and -not $Password) { + Write-Error -Message '-ForceChangePasswordNextSignIn only works together with -Password.' -ErrorId 'PasswordRequired' -Category InvalidArgument + return + } + if (-not $TemporaryAccessPass -and ($PSBoundParameters.ContainsKey('TemporaryAccessPassLifetime') -or $PSBoundParameters.ContainsKey('TemporaryAccessPassUsableOnce'))) { + Write-Error -Message '-TemporaryAccessPassLifetime and -TemporaryAccessPassUsableOnce only work together with -TemporaryAccessPass.' -ErrorId 'TemporaryAccessPassRequired' -Category InvalidArgument + return + } + if ($ForwardTo -and $RemoveForwarding) { + Write-Error -Message 'Use -ForwardTo or -RemoveForwarding, not both.' -ErrorId 'ConflictingForwarding' -Category InvalidArgument + return + } + if ($KeepForwardedCopy -and -not $ForwardTo) { + Write-Error -Message '-KeepForwardedCopy only works together with -ForwardTo.' -ErrorId 'ForwardToRequired' -Category InvalidArgument + return + } + foreach ($p in @($GrantMailboxPermission) + @($RemoveMailboxPermission)) { + if ($null -ne $p -and (-not $p.permission -or -not $p.trusteeId)) { + Write-Error -Message 'Each mailbox permission needs permission (fullAccess, sendAs or sendOnBehalf) and trusteeId, such as @{ permission = ''fullAccess''; trusteeId = '''' }.' -ErrorId 'InvalidMailboxPermission' -Category InvalidArgument + return + } + } + foreach ($c in $GrantCalendarAccess) { + if ($null -ne $c -and (-not $c.trusteeId -or $c.role -notin 'reviewer', 'editor', 'delegate')) { + Write-Error -Message 'Each calendar share needs trusteeId and role (reviewer, editor or delegate), such as @{ trusteeId = ''''; role = ''reviewer'' }.' -ErrorId 'InvalidCalendarAccess' -Category InvalidArgument + return + } + } + $bothWays = @($AllowMailApp | Where-Object { $_ -in $BlockMailApp }) + if ($bothWays) { + Write-Error -Message "Allow or block a mail app, not both: $($bothWays -join ', ')." -ErrorId 'ConflictingMailApp' -Category InvalidArgument + return + } + $groupBothWays = @($AddGroup | Where-Object { $_ -in $RemoveGroup }) + if ($groupBothWays) { + Write-Error -Message "Add the user to a group or remove them from it, not both: $($groupBothWays -join ', ')." -ErrorId 'ConflictingGroup' -Category InvalidArgument + return + } + $body = ConvertTo-InforcerUserBody -BoundParameters $PSBoundParameters + $steps = [System.Collections.Generic.List[string]]::new() + # Mailbox steps: name -> request. Each is queued in Exchange Online and awaited before the next step. + $mailboxCalls = @{} + $addMailboxStep = { + param([string]$Name, [string]$Path, [string]$Method, $Json) + $steps.Add($Name) + $mailboxCalls[$Name] = @{ Path = $Path; Method = $Method; Body = $(if ($null -ne $Json) { $Json | ConvertTo-Json -Depth 10 -Compress }) } + } + if ($body.Count -gt 0) { $steps.Add("update $(@($body.Keys) -join ', ')") } + # Licences are one request (so a swap is atomic). Removing only runs after the mailbox steps, + # so a mailbox is converted to shared before its licence goes. + $licenceFirst = [bool]$AddLicense + if ($licenceFirst) { $steps.Add('change licences') } + if ($AddGroup) { $steps.Add('add to groups') } + if ($RemoveGroup) { $steps.Add('remove from groups') } + if ($MailboxType) { & $addMailboxStep "convert mailbox to $($MailboxType.ToLower())" 'type' PATCH @{ type = $MailboxType.ToLower() } } + if ($EnableArchive) { & $addMailboxStep 'turn on the online archive' 'archive' PATCH @{ enabled = $true } } + if ($PSBoundParameters.ContainsKey('HiddenFromAddressLists')) { + & $addMailboxStep $(if ($HiddenFromAddressLists) { 'hide mailbox from address lists' } else { 'show mailbox in address lists' }) 'addressListVisibility' PATCH @{ hidden = $HiddenFromAddressLists } + } + foreach ($address in $AddEmailAddress | Select-Object -Unique) { & $addMailboxStep "add email address $address" 'emailAddresses' POST @{ address = $address } } + if ($PrimaryEmailAddress) { & $addMailboxStep "make $PrimaryEmailAddress the primary email address" 'emailAddresses' POST ([ordered]@{ address = $PrimaryEmailAddress; primary = $true }) } + foreach ($address in $RemoveEmailAddress | Select-Object -Unique) { & $addMailboxStep "remove email address $address" "emailAddresses/$([System.Uri]::EscapeDataString($address))" DELETE $null } + if ($PSBoundParameters.ContainsKey('AutoReply')) { + $reply = [ordered]@{} + $source = if ($AutoReply -is [System.Collections.IDictionary]) { [pscustomobject]$AutoReply } else { $AutoReply } + foreach ($p in $source.PSObject.Properties) { + # A read can be sent back: nulls and the read-only simplified are left out, dates get an offset. + if ($null -eq $p.Value -or $p.Name -eq 'simplified') { continue } + $reply[$p.Name] = if ($p.Value -is [datetime] -or $p.Value -is [datetimeoffset]) { $p.Value.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'") } else { $p.Value } + } + if ($reply['status'] -eq 'disabled') { $reply = [ordered]@{ status = 'disabled' } } + & $addMailboxStep $(if ($reply['status'] -eq 'disabled') { 'turn off automatic replies' } else { 'set automatic replies' }) 'autoReply' PATCH $reply + } + if ($ForwardTo) { + $forward = [ordered]@{} + $forward[$(if ($ForwardTo -as [guid]) { 'recipientUserId' } else { 'smtpAddress' })] = $ForwardTo + $forward['keepCopy'] = $KeepForwardedCopy.IsPresent + & $addMailboxStep "forward mail to $ForwardTo" 'forwarding' PATCH $forward + } + if ($RemoveForwarding) { & $addMailboxStep 'stop forwarding mail' 'forwarding' DELETE $null } + foreach ($p in $GrantMailboxPermission) { + $grant = [ordered]@{ trusteeId = "$($p.trusteeId)"; permission = "$($p.permission)" } + if ($null -ne $p.automapping) { $grant['automapping'] = [bool]$p.automapping } + & $addMailboxStep "grant $($p.permission) to $($p.trusteeId)" 'permissions' POST $grant + } + foreach ($p in $RemoveMailboxPermission) { + & $addMailboxStep "remove $($p.permission) from $($p.trusteeId)" "permissions/$([System.Uri]::EscapeDataString("$($p.permission)"))/$([System.Uri]::EscapeDataString("$($p.trusteeId)"))" DELETE $null + } + foreach ($c in $GrantCalendarAccess) { + & $addMailboxStep "share calendar with $($c.trusteeId) as $("$($c.role)".ToLower())" 'calendarAccess' POST ([ordered]@{ trusteeId = "$($c.trusteeId)"; role = "$($c.role)".ToLower() }) + } + foreach ($trusteeId in $RemoveCalendarAccess | Select-Object -Unique) { & $addMailboxStep "remove calendar access of $trusteeId" "calendarAccess/$trusteeId" DELETE $null } + foreach ($groupId in $AddMailGroup | Select-Object -Unique) { & $addMailboxStep "add to mail group $groupId" 'mailGroups' POST @{ groupId = "$groupId" } } + foreach ($groupId in $RemoveMailGroup | Select-Object -Unique) { & $addMailboxStep "remove from mail group $groupId" "mailGroups/$groupId" DELETE $null } + foreach ($ruleId in $RemoveInboxRule | Select-Object -Unique) { & $addMailboxStep "remove inbox rule $ruleId" "inboxRules/$([System.Uri]::EscapeDataString($ruleId))" DELETE $null } + if ($RemoveAllInboxRules) { & $addMailboxStep 'remove every inbox rule' 'inboxRules?all=true' DELETE $null } + if ($AllowMailApp -or $BlockMailApp) { + # A case-insensitive lookup gives the API's spelling whatever casing was typed. + $apiName = @{} + foreach ($n in 'outlookWeb', 'outlookDesktop', 'outlookMac', 'exchangeWebServices', 'imap', 'pop', 'outlookApp', 'otherMailApps') { $apiName[$n] = $n } + $apps = [ordered]@{} + foreach ($app in $AllowMailApp) { $apps[$apiName[$app]] = $true } + foreach ($app in $BlockMailApp) { $apps[$apiName[$app]] = $false } + & $addMailboxStep "$(@(if ($AllowMailApp) { "allow $($AllowMailApp -join ', ')" }; if ($BlockMailApp) { "block $($BlockMailApp -join ', ')" }) -join ' and ')" 'mailApps' PATCH $apps + } + if ($RemoveLicense -and -not $licenceFirst) { $steps.Add('change licences') } + if ($Password) { $steps.Add('reset password') } + foreach ($methodId in $RemoveAuthenticationMethod | Select-Object -Unique) { $steps.Add("remove authentication method $methodId") } + if ($ResetMfa) { $steps.Add('reset MFA') } + if ($TemporaryAccessPass) { $steps.Add('create Temporary Access Pass') } + if ($RevokeSessions) { $steps.Add('sign out of every session') } + if ($steps.Count -eq 0) { + Write-Error -Message 'Nothing to change: pass at least one property, such as -Department or -AccountEnabled, or -AddLicense, -RemoveLicense, -AddGroup, -RemoveGroup, a mailbox change (such as -MailboxType, -AutoReply, -ForwardTo, -GrantCalendarAccess or -BlockMailApp), -Password, -RemoveAuthenticationMethod, -ResetMfa, -TemporaryAccessPass or -RevokeSessions.' -ErrorId 'NoChangeSpecified' -Category InvalidArgument + return + } + + try { + $resolvedTenantId = Resolve-InforcerTenantId -TenantId $TenantId + } catch { + Write-Error -Message $_.Exception.Message -ErrorId 'InvalidTenantId' -Category InvalidArgument + return + } + + if (-not $PSCmdlet.ShouldProcess("user $UserId in tenant $resolvedTenantId", ($steps -join '; '))) { return } + + $userEndpoint = "/tenants/$resolvedTenantId/users/$([System.Uri]::EscapeDataString($UserId))" + $done = [System.Collections.Generic.List[string]]::new() + # One step: its error is the answer. Several: hold it back and report what was and wasn't done. + $errorHandling = @{ ErrorVariable = 'stepErr' } + if ($steps.Count -gt 1) { $errorHandling['ErrorAction'] = 'SilentlyContinue' } + foreach ($step in $steps) { + $stepErr = $null + if ($step -eq 'reset password') { + $json = [ordered]@{ + password = ConvertFrom-InforcerSecureString -SecureString $Password + forceChangePasswordNextSignIn = $ForceChangePasswordNextSignIn + } | ConvertTo-Json -Compress + try { + $null = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/password" -Method POST -Body $json @errorHandling + } finally { $json = $null } + } elseif ($step -like 'remove authentication method *') { + $methodId = $step.Substring('remove authentication method '.Length) + $null = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/authenticationMethods/$([System.Uri]::EscapeDataString($methodId))" -Method DELETE @errorHandling + } elseif ($step -eq 'change licences') { + $json = [ordered]@{} + if ($AddLicense) { $json['addSkuIds'] = @($AddLicense | Select-Object -Unique | ForEach-Object { "$_" }) } + if ($RemoveLicense) { $json['removeSkuIds'] = @($RemoveLicense | Select-Object -Unique | ForEach-Object { "$_" }) } + $null = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/assignLicenses" -Method POST -Body ($json | ConvertTo-Json -Compress) @errorHandling + } elseif ($step -in 'add to groups', 'remove from groups') { + $groups = @(if ($step -eq 'add to groups') { $AddGroup } else { $RemoveGroup }) | Select-Object -Unique | ForEach-Object { "$_" } + $json = @{ $(if ($step -eq 'add to groups') { 'add' } else { 'remove' }) = @($groups) } | ConvertTo-Json -Compress + $null = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/groups" -Method POST -Body $json @errorHandling + } elseif ($mailboxCalls.ContainsKey($step)) { + $call = $mailboxCalls[$step] + $request = @{ Endpoint = "$userEndpoint/mailbox/$($call.Path)"; Method = $call.Method } + if ($call.Body) { $request['Body'] = $call.Body } + $action = Invoke-InforcerApiRequest @request @errorHandling + if (-not $stepErr) { $action = Wait-InforcerMailboxAction -UserEndpoint $userEndpoint -ActionId $action.actionId -Step $step -UserId $UserId @errorHandling } + } elseif ($step -eq 'create Temporary Access Pass') { + $json = [ordered]@{} + if ($PSBoundParameters.ContainsKey('TemporaryAccessPassLifetime')) { $json['lifetimeInMinutes'] = $TemporaryAccessPassLifetime } + if ($PSBoundParameters.ContainsKey('TemporaryAccessPassUsableOnce')) { $json['usableOnce'] = $TemporaryAccessPassUsableOnce } + $pass = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/authenticationMethods/temporaryAccessPasses" -Method POST -Body ($json | ConvertTo-Json -Compress) @errorHandling + # Emitted at once: the pass cannot be read again, so a later failing step must not lose it. + if (-not $stepErr -and $pass) { + $pass | Add-Member -NotePropertyName userId -NotePropertyValue $UserId -Force + $pass + } + $pass = $null + } elseif ($step -eq 'reset MFA') { + $null = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/mfa" -Method DELETE @errorHandling + } elseif ($step -eq 'sign out of every session') { + $null = Invoke-InforcerApiRequest -Endpoint "$userEndpoint/revokeSessions" -Method POST @errorHandling + } else { + $null = Invoke-InforcerApiRequest -Endpoint $userEndpoint -Method PATCH -Body ($body | ConvertTo-Json -Depth 100 -Compress) @errorHandling + } + if (-not $stepErr) { $done.Add($step); continue } + + if ($steps.Count -eq 1) { return } + $last = $stepErr[-1] + $skipped = @($steps | Select-Object -Skip ($done.Count + 1)) + $message = "Could not $step for user $UserId. $($last.Exception.Message)" + + $(if ($done.Count) { " Already done: $($done -join '; ')." } else { '' }) + + $(if ($skipped.Count) { " Not done: $($skipped -join '; ')." } else { '' }) + Write-Error -Message $message -ErrorId 'UserUpdatePartlyApplied' -Category $last.CategoryInfo.Category + return + } + } +} diff --git a/module/README.md b/module/README.md index ee7c4d6..082c1f3 100644 --- a/module/README.md +++ b/module/README.md @@ -11,7 +11,7 @@ module/ ├── InforcerCommunity.Format.ps1xml # Default table/list formats ├── InforcerCommunity.Types.ps1xml # Type definitions ├── README.md # This file -├── Public/ # Exported cmdlets (21) +├── Public/ # Exported cmdlets (23) │ ├── Connect-Inforcer.ps1 │ ├── Disconnect-Inforcer.ps1 │ ├── Test-InforcerConnection.ps1 @@ -22,6 +22,8 @@ module/ │ ├── Get-InforcerAuditEvent.ps1 │ ├── Get-InforcerSupportedEventType.ps1 │ ├── Get-InforcerUser.ps1 +│ ├── New-InforcerUser.ps1 +│ ├── Set-InforcerUser.ps1 │ ├── Get-InforcerGroup.ps1 │ ├── Get-InforcerRole.ps1 │ ├── Get-InforcerSecureScore.ps1 diff --git a/scripts/Test-AllCmdlets.ps1 b/scripts/Test-AllCmdlets.ps1 index 15e4989..c1f2328 100644 --- a/scripts/Test-AllCmdlets.ps1 +++ b/scripts/Test-AllCmdlets.ps1 @@ -51,6 +51,13 @@ foreach ($name in $exported) { 'Get-InforcerUser' { $out = & $name -TenantId 1 -ErrorVariable err -ErrorAction SilentlyContinue } + 'New-InforcerUser' { + $pw = ConvertTo-SecureString -String 'dummy' -AsPlainText -Force + $out = & $name -TenantId 1 -DisplayName 'Jo' -UserPrincipalName 'jo@contoso.com' -Password $pw -ErrorVariable err -ErrorAction SilentlyContinue + } + 'Set-InforcerUser' { + $out = & $name -TenantId 1 -UserId '00000000-0000-0000-0000-000000000000' -Department 'Sales' -ErrorVariable err -ErrorAction SilentlyContinue + } 'Get-InforcerGroup' { $out = & $name -TenantId 1 -ErrorVariable err -ErrorAction SilentlyContinue }