Skip to content

Commit

Permalink
Merge pull request #1191 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Offboarding tweaks
  • Loading branch information
JohnDuprey authored Nov 19, 2024
2 parents 96134a8 + 6f1e309 commit ae5f187
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function Push-AuditLogTenant {
# Get webhook rules
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable
$LogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'

Write-Information ("Audit: Memory usage before processing $([System.GC]::GetTotalMemory($false))")
$SearchCount = 0
$Configuration = $ConfigEntries | Where-Object { ($_.Tenants -match $TenantFilter -or $_.Tenants -match 'AllTenants') }
if ($Configuration) {
try {
Expand Down Expand Up @@ -88,12 +89,17 @@ function Push-AuditLogTenant {
}
}
}
$SearchCount++
Write-Information "Audit: Memory usage after processing $SearchCount searches: $([System.GC]::GetTotalMemory($false))"
}
} catch {
Write-Information ( 'Audit Log search: Error {0} line {1} - {2}' -f $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber, $_.Exception.Message)
}
}
} catch {
Write-Information ( 'Push-AuditLogTenant: Error {0} line {1} - {2}' -f $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber, $_.Exception.Message)
} finally {
Write-Information "Audit Logs: Completed processing $($TenantFilter)"
Write-Information "Audit Logs: Memory usage after processing $([System.GC]::GetTotalMemory($false))"
}
}
22 changes: 11 additions & 11 deletions Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ function Invoke-CIPPOffboardingJob {
$userid = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($username)?`$select=id" -tenantid $Tenantfilter).id
Write-Host "Running offboarding job for $username with options: $($Options | ConvertTo-Json -Depth 10)"
$Return = switch ($Options) {
{ $_.'ConvertToShared' -eq 'true' } {
{ $_.'ConvertToShared' -eq $true } {
Set-CIPPMailboxType -ExecutingUser $ExecutingUser -tenantFilter $tenantFilter -userid $username -username $username -MailboxType 'Shared' -APIName $APIName
}
{ $_.RevokeSessions -eq 'true' } {
{ $_.RevokeSessions -eq $true } {
Revoke-CIPPSessions -tenantFilter $tenantFilter -username $username -userid $userid -ExecutingUser $ExecutingUser -APIName $APIName
}
{ $_.ResetPass -eq 'true' } {
{ $_.ResetPass -eq $true } {
Set-CIPPResetPassword -tenantFilter $tenantFilter -userid $username -ExecutingUser $ExecutingUser -APIName $APIName
}
{ $_.RemoveGroups -eq 'true' } {
{ $_.RemoveGroups -eq $true } {
Remove-CIPPGroups -userid $userid -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName -Username "$Username"
}

{ $_.'HideFromGAL' -eq 'true' } {
{ $_.'HideFromGAL' -eq $true } {
Set-CIPPHideFromGAL -tenantFilter $tenantFilter -userid $username -HideFromGAL $true -ExecutingUser $ExecutingUser -APIName $APIName
}
{ $_.'DisableSignIn' -eq 'true' } {
{ $_.'DisableSignIn' -eq $true } {
Set-CIPPSignInState -TenantFilter $tenantFilter -userid $username -AccountEnabled $false -ExecutingUser $ExecutingUser -APIName $APIName
}

Expand All @@ -57,23 +57,23 @@ function Invoke-CIPPOffboardingJob {
Set-CIPPForwarding -userid $userid -username $username -tenantFilter $Tenantfilter -Forward $Options.forward -KeepCopy $KeepCopy -ExecutingUser $ExecutingUser -APIName $APIName
}
}
{ $_.'RemoveLicenses' -eq 'true' } {
{ $_.'RemoveLicenses' -eq $true } {
Remove-CIPPLicense -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName -Schedule
}

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

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

{ $_.'removeMobile' -eq 'true' } {
{ $_.'removeMobile' -eq $true } {
Remove-CIPPMobileDevice -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName
}
{ $_.'removeCalendarInvites' -eq 'true' } {
{ $_.'removeCalendarInvites' -eq $true } {
Remove-CIPPCalendarInvites -userid $userid -username $Username -tenantFilter $Tenantfilter -ExecutingUser $ExecutingUser -APIName $APIName
}
{ $_.'removePermissions' } {
Expand Down

0 comments on commit ae5f187

Please sign in to comment.