A few PowerShell (Exchange 2019) impressions summarized!

%3CLINGO-SUB%20id%3D%22lingo-sub-2082804%22%20slang%3D%22en-US%22%3EA%20few%20PowerShell%20(Exchange%202019)%20impressions%20summarized!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2082804%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Exchange%20Friends%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20this%20article%20I%20have%20summarized%20a%20few%20tasks%20that%20I%20used%20on%20a%20project.%20This%20is%20certainly%20not%20an%20exhaustive%20summary%20when%20it%20comes%20to%20working%20with%20Exchange%2C%20I%20just%20wanted%20to%20summarize%20a%20few%20points.%26nbsp%3BPlease%20start%20with%20the%20following%20steps%20to%20begin%20the%20%22journey%22%20(the%20Hashtags%20are%20comments)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%23Please%26nbsp%3Bstart%26nbsp%3Bthe%26nbsp%3BEMS%26nbsp%3B(Exchange%26nbsp%3BManagement%26nbsp%3BShell)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Get%26nbsp%3Binfos%26nbsp%3Babout%26nbsp%3Bmessaging%26nbsp%3Btracking%26nbsp%3Blog%26nbsp%3Bsettings%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-TransportService%26nbsp%3Bex01%26nbsp%3B%7C%26nbsp%3BFormat-List%26nbsp%3B*tracking*%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23We%26nbsp%3Bcould%26nbsp%3Bconfigure%26nbsp%3Bthe%26nbsp%3BExchange%26nbsp%3Borganization%26nbsp%3Bto%26nbsp%3Bsend%26nbsp%3Bcopies%26nbsp%3Bof%26nbsp%3BNDRs%26nbsp%3Bto%26nbsp%3Bthe%26nbsp%3BExchange%26nbsp%3Brecipient.%26nbsp%3BIs%26nbsp%3Bthere%26nbsp%3Ba%26nbsp%3Bdedicated%26nbsp%3Bmailbox%26nbsp%3Bfor%26nbsp%3Bthe%26nbsp%3BExchange%26nbsp%3Brecipient%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-OrganizationConfig%26nbsp%3B%7C%26nbsp%3BSelect-Object%26nbsp%3BMicrosoftExchangeRecipientReplyRecipient%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23To%26nbsp%3Bdo%26nbsp%3Bso%2C%26nbsp%3Bthis%26nbsp%3Bexample%26nbsp%3Bassigns%26nbsp%3Bthe%26nbsp%3Bexisting%26nbsp%3Bmailbox%26nbsp%3Bnamed%26nbsp%3B%22Contoso%26nbsp%3BSystem%26nbsp%3BMailbox%22%26nbsp%3Bto%26nbsp%3Bthe%26nbsp%3BExchange%26nbsp%3Brecipient%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3ESet-OrganizationConfig%26nbsp%3B-MicrosoftExchangeRecipientReplyRecipient%26nbsp%3B%22Contoso%26nbsp%3BSystem%26nbsp%3BMailbox%22%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23OAuth2ClientProfileEnabled%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-OrganizationConfig%26nbsp%3B%7C%26nbsp%3BSelect-Object%26nbsp%3BOAuth2ClientProfileEnabled%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Are%26nbsp%3Bthere%26nbsp%3Bany%26nbsp%3Bretention%26nbsp%3Bhold%26nbsp%3Benabled%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-Mailbox%26nbsp%3B-ResultSize%26nbsp%3Bunlimited%26nbsp%3B%7C%26nbsp%3BWhere-Object%26nbsp%3B%7B%24_.RetentionHoldEnabled%26nbsp%3B-eq%26nbsp%3B%24true%7D%26nbsp%3B%7C%26nbsp%3BFormat-Table%26nbsp%3BName%2CRetentionPolicy%2CRetentionHoldEnabled%26nbsp%3B-Auto%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Did%26nbsp%3BJane%26nbsp%3Breceive%26nbsp%3Ban%26nbsp%3Bemail%26nbsp%3Bfrom%26nbsp%3Bthe%26nbsp%3Badmin%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%24Temp%26nbsp%3B%3D%26nbsp%3BSearch-MessageTrackingReport%26nbsp%3B-Identity%26nbsp%3B%22exadmin%22%26nbsp%3B-Recipients%26nbsp%3B%22janeford%40contosotom.ch%22%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-MessageTrackingReport%26nbsp%3B-Identity%26nbsp%3B%24Temp.MessageTrackingReportID%26nbsp%3B-ReportTemplate%26nbsp%3BSummary%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Infos%26nbsp%3Babout%26nbsp%3Bcontent%26nbsp%3Bfiltering%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-ContentFilterConfig%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Do%26nbsp%3Bwe%26nbsp%3Bhave%26nbsp%3Ban%26nbsp%3BActive%26nbsp%3BSync%26nbsp%3BRule%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-ActiveSyncDeviceAccessRule%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Infos%26nbsp%3Babout%26nbsp%3Ba%26nbsp%3Bspecific%26nbsp%3Bmailbox%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-Mailbox%26nbsp%3B-Identity%26nbsp%3B%22exadmin%22%26nbsp%3B%7C%26nbsp%3BFormat-List%26nbsp%3B*%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23If%26nbsp%3Byou%26nbsp%3Bneed%26nbsp%3Bto%26nbsp%3Btest%26nbsp%3Bthe%26nbsp%3Binternal%26nbsp%3Bmailflow%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3ETest-Mailflow%26nbsp%3B-TargetEmailAddress%26nbsp%3Bexadmin%40contosotom.ch%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23A%26nbsp%3Blist%26nbsp%3Bof%26nbsp%3Bdistribution%26nbsp%3Bgroups%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-DistributionGroup%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23A%26nbsp%3Bbit%26nbsp%3Bmore%26nbsp%3Bspecific%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-DistributionGroup%26nbsp%3B-Identity%26nbsp%3BIT%26nbsp%3B%7C%26nbsp%3BSelect-Object%26nbsp%3BAcceptMessagesOnlyFrom%2C%26nbsp%3BAcceptMessagesOnlyFromDLMembers%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Find%26nbsp%3Bthe%26nbsp%3Bpermissions%26nbsp%3Brequired%26nbsp%3Bto%26nbsp%3Brun%26nbsp%3Ba%26nbsp%3Bcmdlet%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%24Perms%26nbsp%3B%3D%26nbsp%3BGet-ManagementRole%26nbsp%3B-Cmdlet%26nbsp%3BSet-Mailbox%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%24Perms%26nbsp%3B%7C%26nbsp%3BForEach-Object%26nbsp%3B%7BGet-ManagementRoleAssignment%26nbsp%3B-Role%26nbsp%3B%24_.Name%26nbsp%3B-Delegating%26nbsp%3B%24false%26nbsp%3B%7C%26nbsp%3BFormat-Table%26nbsp%3B-Auto%26nbsp%3BRole%2CRoleAssigneeType%2CRoleAssigneeName%7D%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Need%26nbsp%3Bhelp%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-Help%26nbsp%3BSet-CASMailbox%26nbsp%3B-Full%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3EI%20am%20absolutely%20aware%20that%20this%20is%20nothing%20spectacular.%20I%20just%20wanted%20to%20share%20a%20few%20impressions%20with%20you.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CP%3EI%20hope%20this%20article%20was%20useful.%20Best%20regards%2C%20Tom%20Wechsler%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EP.S.%26nbsp%3BAll%20scripts%20(%23PowerShell%2C%20Azure%20CLI%2C%20%23Terraform%2C%20%23ARM)%20that%20I%20use%20can%20be%20found%20on%20github!%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftomwechsler%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Ftomwechsler%3C%2FA%3E%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2082804%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Contributor

 

Hi Exchange Friends,

 

In this article I have summarized a few tasks that I used on a project. This is certainly not an exhaustive summary when it comes to working with Exchange, I just wanted to summarize a few points. Please start with the following steps to begin the "journey" (the Hashtags are comments):

 

#Please start the EMS (Exchange Management Shell)

#Get infos about messaging tracking log settings
Get-TransportService ex01 | Format-List *tracking*

#We could configure the Exchange organization to send copies of NDRs to the Exchange recipient. Is there a dedicated mailbox for the Exchange recipient?
Get-OrganizationConfig | Select-Object MicrosoftExchangeRecipientReplyRecipient

#To do so, this example assigns the existing mailbox named "Contoso System Mailbox" to the Exchange recipient
Set-OrganizationConfig -MicrosoftExchangeRecipientReplyRecipient "Contoso System Mailbox"

#OAuth2ClientProfileEnabled?
Get-OrganizationConfig | Select-Object OAuth2ClientProfileEnabled

#Are there any retention hold enabled?
Get-Mailbox -ResultSize unlimited | Where-Object {$_.RetentionHoldEnabled -eq $true} | Format-Table Name,RetentionPolicy,RetentionHoldEnabled -Auto

#Did Jane receive an email from the admin?
$Temp = Search-MessageTrackingReport -Identity "exadmin" -Recipients "janeford@contosotom.ch"
Get-MessageTrackingReport -Identity $Temp.MessageTrackingReportID -ReportTemplate Summary

#Infos about content filtering
Get-ContentFilterConfig

#Do we have an Active Sync Rule?
Get-ActiveSyncDeviceAccessRule

#Infos about a specific mailbox
Get-Mailbox -Identity "exadmin" | Format-List *

#If you need to test the internal mailflow
Test-Mailflow -TargetEmailAddress exadmin@contosotom.ch

#A list of distribution groups
Get-DistributionGroup

#A bit more specific
Get-DistributionGroup -Identity IT | Select-Object AcceptMessagesOnlyFrom, AcceptMessagesOnlyFromDLMembers

#Find the permissions required to run a cmdlet
$Perms = Get-ManagementRole -Cmdlet Set-Mailbox
$Perms | ForEach-Object {Get-ManagementRoleAssignment -Role $_.Name -Delegating $false | Format-Table -Auto Role,RoleAssigneeType,RoleAssigneeName}

#Need help?
Get-Help Set-CASMailbox -Full
 
I am absolutely aware that this is nothing spectacular. I just wanted to share a few impressions with you.
 

I hope this article was useful. Best regards, Tom Wechsler

 

P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler

0 Replies