User Tools

Site Tools


internet:mail:exchange:exchange_o365_powershell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
internet:mail:exchange:exchange_o365_powershell [2019/01/09 13:56]
jcooper created
internet:mail:exchange:exchange_o365_powershell [2019/01/30 10:57] (current)
jcooper
Line 1: Line 1:
-====== Using the Exchange Shell to Track Failed Message Delivery ====== +====== Connect to Office 365 Exchange via PowerShell ======
- +
-[[https://practical365.com/exchange-server/searching-message-tracking-logs-by-sender-or-recipient-email-address/|Exchange Message Tracking from the Command Line]] +
- +
-You can use the Exchange shell to track messages that could not be delivered because of message size issues. The RecipientStatus field in Message Tracking logs is used to store the SMTP response and enhanced status codes. The Message Tracking EventID we’re looking for is FAIL. +
- +
-**To track messages that failed because of recipient’s MaxReceiveSize:**+
  
 +  * On the machine you are connecting from install the ''Microsoft Online Services Sign-in Assistant'' module.
 +https://www.microsoft.com/en-us/download/details.aspx?id=41950
 +  * Open PowerShell run as administrator.
 +  * Allow remote signing.
 <file> <file>
-Get-MessageTrackingLog -EventID FAIL | where {$_.RecipientStatus -like “*RecipSizeLimit*”}+Set-ExecutionPolicy RemoteSigned
 </file> </file>
- +  Set cached credentials. You need the global admin account credentials 
-**To track messages that failed because of the sender’s MaxSendSize:** +
 <file> <file>
-Get-MessageTrackingLog -EventID FAIL | where {$_.RecipientStatus -like “*SendSizeLimit*”}+$LiveCred = Get-Credential
 </file> </file>
- +  Setup parameters for the session.
-**To track messages from a particular sender:** +
 <file> <file>
-Get-MessageTrackingLog -sender "foo@somedomain.com"+$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection 
 +</file> 
 +  * Open a session. 
 +<file> 
 +Import-PSSession $Session 
 +</file> 
 +  * Close a session. 
 +<file> 
 +Remove-PSSession $Session 
 +</file>
  
-Get-MessageTrackingLog -Sender foo@somedomain.com -Start (Get-Date).AddHours(-1)+====== PowerShell rules commands ======
  
-Get-MessageTrackingLog -Sender foo@somedomain.com -Recipients foo@mydomain.com+https://www.codetwo.com/admins-blog/managing-outlook-rules-powershell/
  
-Get-MessageTrackingLog -Sender foo@somedomain.com -Recipients foo@mydomain.com,another@mydomain.com+https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/remove-inboxrule?view=exchange-ps
  
-</file>+  * Get Inbox Rule
  
-**Find messages by recipient:**+:!: To get the entire RuleIdentity you may need to widen the PowerShell window.  Properties, Layout, window size, width. 
  
 <file> <file>
-Get-MessageTrackingLog -Recipients "foo@mydomain.com"+Get-InboxRule -Mailbox <mailbox_name> 
 +</file> 
 +  * Get Inbox Rule and show what it does 
 +<file> 
 +Get-InboxRule –Mailbox <mailbox_user> | Select Name, Description | FL 
 +</file> 
 +  * Get Inbox Rule and show details 
 +<file> 
 +Get-InboxRule -Identity <RuleIdentity> -Mailbox <mailbox_user> | FL 
 +</file> 
 +  * Remove Inbox rule 
 +<file> 
 +Remove-InboxRule -Identity <rule_name> -Mailbox <mailbox_name> 
 +</file> 
 +  * Remove all Inbox rules 
 +<file> 
 +Get-InboxRule -Mailbox <mailbox_name> | Remove-InboxRule 
 +</file>
  
-Get-MessageTrackingLog -Recipients *@gmail.com 
  
-Get-MessageTrackingLog -Start (Get-Date).AddHours(-1) | Where-Object {$_.recipients -like "*@gmail.com"} 
- 
-Get-MessageTrackingLog -Start (Get-Date).AddHours(-1) | Where-Object {$_.recipients -match "gmail"} 
-</file> 
  
-:!: The ''-match'' comparison operator **does not require** the wildcard character. 
internet/mail/exchange/exchange_o365_powershell.1547067412.txt.gz · Last modified: 2019/01/09 13:56 by jcooper