Prerequisites:
Exchange Admins need these three roles to perform operations on mailboxes: Mailbox Search, Mailbox Import Export, and Discovery Management
Command:
 
New-ManagementRoleAssignment -Name "Import Export_Organization Management" -SecurityGroup "Organization Management" -Roles "Mailbox Import Export","Mailbox Search","Discovery Management"
 
# When someone has accidentally deleted some items and subsequently removed them from the trash bin, those items are held in pending-purgatory. To recover these items, the Admin would run these commands to locate the deleted items (inside Recovery folder) and place items into a temp location:
 
$originalMailbox="Tech Support"
$tempMailbox="kimconnect"

Search-Mailbox $originalMailbox -SearchQuery {received:01/01/2018..01/22/2019} -TargetMailbox $tempMailbox -TargetFolder $originalMailbox+" Recovery"
 
# Recover messages to original mailbox
 
Search-Mailbox $tempMailbox -SearchQuery {To:"[email protected]" OR From:"[email protected]" OR Cc:"[email protected]" } -TargetMailbox $originalMailbox -TargetFolder "Mail Items From 1-1-18 to 1-22-19" -DeleteContent
# Remove repeated calendar item set by a deleted user
# Get MailboxGuid and save it as into variables
$displayName="Kim Connect"
$mailbox=Get-MailboxDatabase | Get-MailboxStatistics | where {$_.DisplayName -eq $displayName}
$mailboxID=$mailbox.MailboxGuid;
$mailboxDatabase=$mailbox.Database;
# Create Test Mailbox
# Added "NTFS, Test" mailbox > hide from Exchange address list
# Manage Full Access Permission of "NTFS, Test" > add kimconnect on the list

# Restore mailbox
New-MailboxRestoreRequest -SourceStoreMailbox $mailboxID -SourceDatabase $mailboxDatabase -TargetMailbox "NTFS, Test" -AllowLegacyDNMismatch
# Script to re-attach a disabled mailbox to its original user account
$user="kimconnect";
$mailbox=Get-MailboxDatabase | Get-MailboxStatistics | where {$_.DisplayName -eq $user};
$mailboxDatabase=$mailbox.Database;
Connect-Mailbox -Identity $user -Database $mailboxDatabase -User $user

# Grant Full Access
$accessGrant="Kim Connect"
$targetMailbox="Tech Support"
Add-MailboxPermission $targetMailbox -User $accessGrant -AccessRights FullAccess -InheritanceType all
 
# Repair mailbox
New-MailboxRepairRequest -Mailbox $targetMailbox -CorruptionType ProvisionedFolder,SearchFolder,AggregateCounts,Folderview
 
# Set permissions on folders and sub-folders
# For Exchange 2010, download ExFolders ) > Place contents into "D:\Program Files\Microsoft\Exchange Server\v14\Bin" folder on EXCHANGE02 > Apply the registry fix "TurnOffSNVerificationForExFolders.reg" > Use that tool to set folder permissions
# When done just change Add to Remove:
Remove-MailboxPermission -Identity "Test" -User Administrator -AccessRights Fullaccess -InheritanceType all
 
# Purge mail items from a mailbox
Search-mailbox -identity "NTFS, Test" -searchquery {sent:01/01/2017..02/8/2019 OR received:01/01/2017..02/8/2019} -DeleteContent