File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Modules/CIPPCore/Public/Entrypoints Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,21 @@ Function Invoke-ListInactiveAccounts {
11
11
param ($Request , $TriggerMetadata )
12
12
13
13
$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'
15
16
16
17
17
18
# Write to the Azure Functions log stream.
18
19
Write-Host ' PowerShell HTTP trigger function processed a request.'
19
20
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
21
22
$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
+
23
29
try {
24
30
$GraphRequest = New-GraphGetRequest - uri " https://graph.microsoft.com/beta/tenantRelationships/managedTenants/inactiveUsers?`$ count=true" - tenantid $env: TenantID | Where-Object { $_.tenantId -in $TenantFilter }
25
31
$StatusCode = [HttpStatusCode ]::OK
@@ -34,5 +40,4 @@ Function Invoke-ListInactiveAccounts {
34
40
StatusCode = $StatusCode
35
41
Body = @ ($GraphRequest )
36
42
})
37
-
38
43
}
You can’t perform that action at this time.
0 commit comments