Advertisement
D0cEvil

Exchange Online - Restore from Quarantine

Dec 6th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.99 KB | Cybersecurity | 0 0
  1. # Подключаем модуль
  2.  
  3. Import-Module ExchangeOnlineManagement
  4.  
  5. $UserPrincipalName = Read-Host "Please put your UserPrincipalName"
  6.  
  7. # Подключаемся к Excange
  8.  
  9. Connect-IPPSSession -UserPrincipalName $UserPrincipalName
  10.  
  11. # Запрашиваем адрес
  12.  
  13. $mail_address = Read-Host "Please put the Mail address"
  14.  
  15. # Получаем MessageID и пишем в файл
  16.  
  17. Get-QuarantineMessage -SenderAddress "$mail_address"| Format-Table Identity -HideTableHeaders | Out-File "C:\quarantined.txt"
  18.  
  19. # Чистим файл от пустых линий
  20.  
  21. Get-Content "C:\quarantined.txt" | where {$_ -ne ""} | Out-File "C:\quarantined1.txt"
  22.  
  23. $mail_id = Get-Content "C:\quarantined1.txt"
  24.  
  25. # Восстанавливаем каждое сообщение
  26.  
  27. Foreach ($line in $mail_id )
  28. {
  29.    
  30.    Release-QuarantineMessage -Identity $line -ReleaseToAll
  31.    
  32. }
  33.  
  34. # Удаляем файлики
  35.  
  36. Remove-Item "C:\quarantined.txt"
  37. Remove-Item "C:\quarantined1.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement