Most useful PowerShell commands for Exchange

From Tech-Wiki
Revision as of 21:09, 6 June 2019 by Fabricio.Lima (Talk | contribs) (Created page with "Category:Microsoft '''Back to Misc''' '''Assign Mailbox Permissions''' Assign “Full Access” permissions for a Mailbox PowerShell command Syntax...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to Misc

Assign Mailbox Permissions

Assign “Full Access” permissions for a Mailbox

PowerShell command Syntax
Add-MailboxPermission <Identity> -User <Identity> -AccessRights FullAccess -InheritanceType All
PowerShell command Example
Add-MailboxPermission John -User Suzan -AccessRights FullAccess -InheritanceType All

Assign “Send As” Permissions for a Mailbox

PowerShell command Syntax
Add-RecipientPermission <Identity> -AccessRights SendAs -Trustee <Identity>
PowerShell command Example
Add-RecipientPermission John -AccessRights SendAs -Trustee Suzan
Adjustments & Improvements
To avoid the need for confirmation, we can add the option: “-Confirm:$False”
Add-RecipientPermission John -Trustee Suzan -AccessRights SendAs -Confirm:$False

Assign “Send As” Permissions for recipient for each member in a distribution group

PowerShell command Syntax
$DL = Get-DistributionGroupMember 
Foreach ($item in $DL) 
{ 
Add-RecipientPermission $item.name -AccessRights SendAs
–Trustee <Identity> -Confirm:$False 
}
PowerShell command Example
$DL = Get-DistributionGroupMember DL-01 
Foreach ($item in $DL) 
{ 
Add-RecipientPermission $item.name -AccessRights SendAs –Trustee Suzan -Confirm:$False}

Display permissions for a Mailbox

Display “Full Access” Permissions for a Mailbox

PowerShell command Syntax
Get-MailboxPermission <Identity>
PowerShell command Example
Get-MailboxPermission John
Adjustments & Improvements
For improving the quality of the output we can use an additional PowerShell parameter that will “clean” the unnecessary information:
Get-MailboxPermission John | Where { ($_.IsInherited -eq $False) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | Select Identity,user,AccessRights

Revoke Permissions

Revoke “Full Access” Permissions

PowerShell command Syntax
Remove-MailboxPermission <Identity> -User <Identity> -AccessRights FullAccess
PowerShell command Example
Remove-MailboxPermission John -User Suzan -AccessRights FullAccess
Adjustments & Improvements
To avoid the need for confirmation, we can add the option: “-Confirm:$False”
Remove-MailboxPermission John -User Suzan -AccessRights FullAccess -Confirm:$False

Migration statistics

Get-MigrationUser -BatchId StagedBatch1 | Get-MigrationUserStatistics

Message Tracking log

Get-MessageTrackingLog -Start "02/26/2018 08:23:00" -End "02/28/2018 17:00:00" -Recipients $recipientSMTP -Server $ExchServer

Set Auto-Reply

Set-MailboxAutoReplyConfiguration -Identity "Desmond Miles" -AutoReplyState Enabled `
-InternalMessage "I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters."
AutoReplyState can also be: AutoReplyState Scheduled –StartTime “02/28/2018 07:00:00” –EndTime 03/18/2018 17:00:00

Office 365 commands:

https://blog.netwrix.com/2018/09/19/ten-most-useful-office-365-powershell-commands/