Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Monitor Large Outlook Files
- Import-Module $env:SyncroModule -DisableNameChecking
- $LargeFileSize = '45' # In gigabytes (Outlook default maximum size is 50GB, can be changed via registry)
- # Sanitize and convert input to bytes
- $LargeFileSize = [int64]$LargeFileSize.Replace('GB', '') * 1GB
- # Get Outlook files from all user profile folders
- $OutlookFiles = @(Get-ItemProperty "$env:SystemDrive\Users\*\AppData\Local\Microsoft\Outlook\*.ost")
- $OutlookFiles += Get-ItemProperty "$env:SystemDrive\Users\*\AppData\Local\Microsoft\Outlook\*.pst"
- $OutlookFiles += Get-ItemProperty "$env:SystemDrive\Users\*\Documents\Outlook Files\*.pst"
- # Look for large Outlook files and output in our preferred format
- $LargeOutlookFiles = foreach ($OutlookFile in $OutlookFiles) {
- if ($OutlookFile.Length -gt $LargeFileSize) {
- [PSCustomObject] @{
- 'Filename' = -join $OutlookFile.Name[0..65] # Trim to keep table formatting
- 'Size in GB' = [math]::Round(($OutlookFile.Length / 1GB), 2) # Convert to GB with 2 decimal places
- 'Last Modified' = $OutlookFile.LastWriteTime
- }
- }
- }
- if ($LargeOutlookFiles) {
- $LargeOutlookFiles = $LargeOutlookFiles | Out-String
- $LargeOutlookFiles
- Rmm-Alert -Category 'Outlook' -Body "Large Outlook Files Found: $LargeOutlookFiles"
- } else {
- "No large Outlook files found."
- Close-Rmm-Alert -Category 'Outlook'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement