V
V
Vasya Pupkin2022-03-04 10:16:24
PowerShell
Vasya Pupkin, 2022-03-04 10:16:24

Which cmdlet to use for mail delete masses?

Comrades, I do not rummage in programming from the word "absolutely".
Prompt with a cmdlet in powershell for exchange online. There are figuratively 10/50/100 boxes, you need to delete all outgoing to internal addresses from one box before a certain date. And on the rest, respectively, all incoming from this address until a certain date.
The easiest way I think to do in two stages (for example):
1. Address A. Delete outgoing letters to internal addresses that were sent before 01/01/2022
2. Delete incoming letters received before 01/01/2022, where the sender specified Address A.

From the original installation and connection, everything is clear:

Set-ExecutionPolicy RemoteSigned
Install-Module PowershellGet -Force
Update-Module PowershellGet
Install-Module -Name ExchangeOnlineManagement -Force -Scope AllUsers
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName [email protected] -ShowProgress $true

But then, just forget it, a bunch of cmdlets, you can’t correctly configure the filtering (selection) for subsequent deletion.

If anyone has done this, I'd appreciate the help.

UPD2 : I'm trying
Soft removal, but it doesn't work. The mail remains in the box and I can see it, although the search worked, the deletion worked.

PS C:\WINDOWS\system32> <b>Get-ComplianceSearch -Identity "search2"| FL name,items,size,jobprogress,status</b>

Name        : search2
Items       : 61103
Size        : 23219880639
JobProgress : 100
Status      : Completed

PS C:\WINDOWS\system32> <b>New-ComplianceSearchAction -SearchName "search2" -Purge -PurgeType SoftDelete</b>                                                                                                                  
Confirm
Are you sure you want to perform this action?
Эта операция сделает элементы сообщения, удовлетворяющие критериям поиска соответствия "search2", недоступными для пользователей. Вы не сможете автоматически отменить удаление этих элементов сообщения.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Справка (значением по умолчанию является "Y"): A

Name          SearchName Action RunBy                   JobEndTime Status
----          ---------- ------ -----                   ---------- ------
search2_Purge search2    Purge  Системный администратор            Starting



PS C:\WINDOWS\system32> <b>Get-ComplianceSearchAction -Identity "search2_Purge"</b>

Name          SearchName Action RunBy                   JobEndTime         Status
----          ---------- ------ -----                   ----------         ------
search2_Purge search2    Purge  Системный администратор 05.03.2022 9:19:13 Completed

PS C:\WINDOWS\system32>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Bezrukov, 2022-03-04
@NortheR73

1. PS on the screenshot clearly says that the error is in the "sender" parameter - there is no such parameter, there is a "from" parameter ( description ). Accordingly, the search query is not formed, as indicated by the last lines with empty Name fields, etc. Dates must be specified in the format mm/dd/yyyy
2. Search query (after creation) is performed via

Start-ComplianceSearch -Identity "ContentSearch_for_Report2022"

3. Removal:
New-ComplianceSearchAction -SearchName "ContentSearch_for_Report2022" -Purge -PurgeType HardDelete

All actions are detailed, at least here and here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question