From 622fc04f38a3d5c5435b9ce772b32d592e57bf2d Mon Sep 17 00:00:00 2001 From: John Duprey Date: Tue, 19 Nov 2024 12:58:51 -0500 Subject: [PATCH 1/2] memory usage tracking --- .../Activity Triggers/Webhooks/Push-AuditLogTenant.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1 index b5cb9286edc5..eee642d90665 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1 @@ -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 { @@ -88,6 +89,8 @@ 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) @@ -95,5 +98,8 @@ function Push-AuditLogTenant { } } 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))" } } From 49df7d07d6d140ad19e111606cdda98afdefebb1 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Tue, 19 Nov 2024 17:49:50 -0500 Subject: [PATCH 2/2] update 'true' to $true --- .../Public/Invoke-CIPPOffboardingJob.ps1 | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 b/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 index 2de463c0c811..a1732cbf6fd9 100644 --- a/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 +++ b/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 @@ -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 } @@ -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' } {