aleinss

Untitled

Nov 7th, 2025
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. # Requires ExchangeOnlineManagement 3.3.0+ (PowerShell 5.1 OK)
  2.  
  3. Import-Module ExchangeOnlineManagement
  4. #Connect-IPPSSession # compliance endpoint
  5. Connect-IPPSSession -EnableSearchOnlySession
  6.  
  7. $SearchName = '11072025_01'
  8. $GroupMailboxes = @(
  9. )
  10.  
  11. $KqlQuery = @'
  12. kind:email
  13. AND from:"[email protected]"
  14. '@
  15.  
  16.  
  17. #$KqlQuery = @'
  18. #kind:email
  19. #AND received>=2025-09-22T05:00:00Z
  20. #AND received<2025-09-23T05:00:00Z
  21. #AND from:"[email protected]"
  22. #'@
  23.  
  24. #$KqlQuery = @'
  25. #kind:email AND
  26. #(from:"[email protected]" OR
  27. # from:"[email protected]" OR
  28. # from:"[email protected]" OR
  29. # from:"[email protected]" OR
  30. #'@
  31.  
  32.  
  33. # Remove existing search if it exists
  34. if (Get-ComplianceSearch -Identity $SearchName -ErrorAction SilentlyContinue) {
  35. Remove-ComplianceSearch -Identity $SearchName -Confirm:$false
  36. }
  37.  
  38. # Create search with the correct sources
  39. New-ComplianceSearch `
  40. -Name $SearchName `
  41. -ExchangeLocation $GroupMailboxes `
  42. -ContentMatchQuery $KqlQuery
  43.  
  44. Start-ComplianceSearch -Identity $SearchName
  45. Get-ComplianceSearch -Identity $SearchName
  46.  
  47. #Remove-ComplianceSearch -Identity 09112025_2 -Confirm:$false
Advertisement
Add Comment
Please, Sign In to add comment