File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -17,17 +17,20 @@ Function Invoke-RemoveUser {
17
17
# Interact with query parameters or the body of the request.
18
18
$TenantFilter = $Request.Query.tenantFilter ?? $Request.Body.tenantFilter
19
19
$UserID = $Request.Query.ID ?? $Request.Body.ID
20
+ $UserPrincipalName = $Request.Query.userPrincipalName ?? $Request.Body.userPrincipalName
20
21
21
22
if (! $UserID ) { exit }
22
23
try {
23
24
$null = New-GraphPostRequest - uri " https://graph.microsoft.com/beta/users/$ ( $UserID ) " - type DELETE - tenant $TenantFilter
24
- $Result = " Successfully deleted $UserID ."
25
+ $Result = " Successfully deleted user with ID: '$UserID '"
26
+ if ($UserPrincipalName ) { $Result += " and User Principal Name: '$UserPrincipalName '" }
25
27
Write-LogMessage - Headers $Headers - API $APIName - message $Result - Sev ' Info' - tenant $TenantFilter
26
28
$StatusCode = [HttpStatusCode ]::OK
27
29
28
30
} catch {
29
31
$ErrorMessage = Get-CippException - Exception $_
30
- $Result = " Could not delete user $ ( $UserID ) . $ ( $ErrorMessage.NormalizedError ) "
32
+ $Result = " Failed to delete user $ ( $UserID ) . $ ( $ErrorMessage.NormalizedError ) "
33
+ if ($UserPrincipalName ) { $Result += " User Principal Name: '$ ( $UserPrincipalName ) '" }
31
34
Write-LogMessage - Headers $Headers - API $APIName - message $Result - Sev ' Error' - tenant $TenantFilter - LogData $ErrorMessage
32
35
$StatusCode = [HttpStatusCode ]::InternalServerError
33
36
}
You can’t perform that action at this time.
0 commit comments