Skip to content

Commit ae5f187

Browse files
authored
Merge pull request KelvinTegelaar#1191 from JohnDuprey/dev
Offboarding tweaks
2 parents 96134a8 + 6f1e309 commit ae5f187

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ function Push-AuditLogTenant {
3232
# Get webhook rules
3333
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable
3434
$LogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
35-
35+
Write-Information ("Audit: Memory usage before processing $([System.GC]::GetTotalMemory($false))")
36+
$SearchCount = 0
3637
$Configuration = $ConfigEntries | Where-Object { ($_.Tenants -match $TenantFilter -or $_.Tenants -match 'AllTenants') }
3738
if ($Configuration) {
3839
try {
@@ -88,12 +89,17 @@ function Push-AuditLogTenant {
8889
}
8990
}
9091
}
92+
$SearchCount++
93+
Write-Information "Audit: Memory usage after processing $SearchCount searches: $([System.GC]::GetTotalMemory($false))"
9194
}
9295
} catch {
9396
Write-Information ( 'Audit Log search: Error {0} line {1} - {2}' -f $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber, $_.Exception.Message)
9497
}
9598
}
9699
} catch {
97100
Write-Information ( 'Push-AuditLogTenant: Error {0} line {1} - {2}' -f $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber, $_.Exception.Message)
101+
} finally {
102+
Write-Information "Audit Logs: Completed processing $($TenantFilter)"
103+
Write-Information "Audit Logs: Memory usage after processing $([System.GC]::GetTotalMemory($false))"
98104
}
99105
}

Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ function Invoke-CIPPOffboardingJob {
1515
$userid = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($username)?`$select=id" -tenantid $Tenantfilter).id
1616
Write-Host "Running offboarding job for $username with options: $($Options | ConvertTo-Json -Depth 10)"
1717
$Return = switch ($Options) {
18-
{ $_.'ConvertToShared' -eq 'true' } {
18+
{ $_.'ConvertToShared' -eq $true } {
1919
Set-CIPPMailboxType -ExecutingUser $ExecutingUser -tenantFilter $tenantFilter -userid $username -username $username -MailboxType 'Shared' -APIName $APIName
2020
}
21-
{ $_.RevokeSessions -eq 'true' } {
21+
{ $_.RevokeSessions -eq $true } {
2222
Revoke-CIPPSessions -tenantFilter $tenantFilter -username $username -userid $userid -ExecutingUser $ExecutingUser -APIName $APIName
2323
}
24-
{ $_.ResetPass -eq 'true' } {
24+
{ $_.ResetPass -eq $true } {
2525
Set-CIPPResetPassword -tenantFilter $tenantFilter -userid $username -ExecutingUser $ExecutingUser -APIName $APIName
2626
}
27-
{ $_.RemoveGroups -eq 'true' } {
27+
{ $_.RemoveGroups -eq $true } {
2828
Remove-CIPPGroups -userid $userid -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName -Username "$Username"
2929
}
3030

31-
{ $_.'HideFromGAL' -eq 'true' } {
31+
{ $_.'HideFromGAL' -eq $true } {
3232
Set-CIPPHideFromGAL -tenantFilter $tenantFilter -userid $username -HideFromGAL $true -ExecutingUser $ExecutingUser -APIName $APIName
3333
}
34-
{ $_.'DisableSignIn' -eq 'true' } {
34+
{ $_.'DisableSignIn' -eq $true } {
3535
Set-CIPPSignInState -TenantFilter $tenantFilter -userid $username -AccountEnabled $false -ExecutingUser $ExecutingUser -APIName $APIName
3636
}
3737

@@ -57,23 +57,23 @@ function Invoke-CIPPOffboardingJob {
5757
Set-CIPPForwarding -userid $userid -username $username -tenantFilter $Tenantfilter -Forward $Options.forward -KeepCopy $KeepCopy -ExecutingUser $ExecutingUser -APIName $APIName
5858
}
5959
}
60-
{ $_.'RemoveLicenses' -eq 'true' } {
60+
{ $_.'RemoveLicenses' -eq $true } {
6161
Remove-CIPPLicense -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName -Schedule
6262
}
6363

64-
{ $_.'Deleteuser' -eq 'true' } {
64+
{ $_.'deleteuser' -eq $true } {
6565
Remove-CIPPUser -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName
6666
}
6767

68-
{ $_.'removeRules' -eq 'true' } {
68+
{ $_.'removeRules' -eq $true } {
6969
Write-Host "Removing rules for $username"
7070
Remove-CIPPMailboxRule -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName -RemoveAllRules
7171
}
7272

73-
{ $_.'removeMobile' -eq 'true' } {
73+
{ $_.'removeMobile' -eq $true } {
7474
Remove-CIPPMobileDevice -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName
7575
}
76-
{ $_.'removeCalendarInvites' -eq 'true' } {
76+
{ $_.'removeCalendarInvites' -eq $true } {
7777
Remove-CIPPCalendarInvites -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName
7878
}
7979
{ $_.'removePermissions' } {

0 commit comments

Comments
 (0)