Skip to content

Commit 457abf3

Browse files
Merge pull request #1196 from kris6673/interface-rewrite
Fix inactive accounts report
2 parents 3e96c87 + a9d3007 commit 457abf3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Modules/CIPPCore/Public/Entrypoints/Invoke-ListInactiveAccounts.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ Function Invoke-ListInactiveAccounts {
1111
param($Request, $TriggerMetadata)
1212

1313
$APIName = $TriggerMetadata.FunctionName
14-
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
14+
$User = $request.headers.'x-ms-client-principal'
15+
Write-LogMessage -user $User -API $APINAME -message 'Accessed this API' -Sev 'Debug'
1516

1617

1718
# Write to the Azure Functions log stream.
1819
Write-Host 'PowerShell HTTP trigger function processed a request.'
1920

20-
# Interact with query parameters or the body of the request.
21+
# Convert the TenantFilter parameter to a list of tenant IDs for AllTenants or a single tenant ID
2122
$TenantFilter = $Request.Query.TenantFilter
22-
if ($TenantFilter -eq 'AllTenants') { $TenantFilter = (get-tenants).customerId }
23+
if ($TenantFilter -eq 'AllTenants') {
24+
$TenantFilter = (Get-Tenants).customerId
25+
} else {
26+
$TenantFilter = (Get-Tenants -TenantFilter $TenantFilter).customerId
27+
}
28+
2329
try {
2430
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/managedTenants/inactiveUsers?`$count=true" -tenantid $env:TenantID | Where-Object { $_.tenantId -in $TenantFilter }
2531
$StatusCode = [HttpStatusCode]::OK
@@ -34,5 +40,4 @@ Function Invoke-ListInactiveAccounts {
3440
StatusCode = $StatusCode
3541
Body = @($GraphRequest)
3642
})
37-
3843
}

0 commit comments

Comments
 (0)