Use the Exchange Online PowerShell to collect information!

%3CLINGO-SUB%20id%3D%22lingo-sub-1944569%22%20slang%3D%22en-US%22%3EUse%20the%20Exchange%20Online%20PowerShell%20to%20collect%20information!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1944569%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Microsoft%20365%20and%20Exchange%20Online%20friends%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20used%20the%20PowerShell%20ISE%20for%20this%20configuration.%20But%20you%20are%20also%20very%20welcome%20to%20use%20Visual%20Studio%20Code%2C%20just%20as%20you%20wish.%26nbsp%3BPlease%20start%20with%20the%20following%20steps%20to%20begin%20the%20deployment%20(the%20Hashtags%20are%20comments)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23The%20first%20two%20lines%20have%20nothing%20to%20do%20with%20the%20configuration%2C%20but%20make%20some%20space%20below%20in%20the%20blue%20part%20of%20the%20ISE%3C%2FP%3E%3CP%3E%3CSTRONG%3ESet-Location%20C%3A%5CTemp%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3EClear-Host%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%23We%26nbsp%3Bneed%26nbsp%3Bthe%26nbsp%3Bmodule%26nbsp%3B(without%26nbsp%3Bthe%26nbsp%3Bparameter%26nbsp%3Bfor%26nbsp%3Ba%26nbsp%3Bspecific%26nbsp%3Bversion)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EInstall-Module%26nbsp%3B-Name%26nbsp%3BExchangeOnlineManagement%26nbsp%3B-AllowClobber%26nbsp%3B-Force%26nbsp%3B-Verbose%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23More%26nbsp%3Bspecific%26nbsp%3Bif%26nbsp%3Byou%26nbsp%3Bwant%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EInstall-Module%26nbsp%3B-Name%26nbsp%3BExchangeOnlineManagement%26nbsp%3B-RequiredVersion%26nbsp%3B2.0.3%26nbsp%3B-AllowClobber%26nbsp%3B-Force%26nbsp%3B-Verbose%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Let's%26nbsp%3Bimport%26nbsp%3Bthe%26nbsp%3Bmodule%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EImport-Module%26nbsp%3BExchangeOnlineManagement%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Check%26nbsp%3Bthe%26nbsp%3Bversion%20(if%20you%20have%20not%20selected%20a%20version)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-InstalledModule%26nbsp%3B-Name%26nbsp%3BExchangeOnlineManagement%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Variable%26nbsp%3Bfor%26nbsp%3Bthe%20credential%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%24UserCredential%26nbsp%3B%3D%26nbsp%3BGet-Credential%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Now%26nbsp%3Bwe%26nbsp%3Bconnect%26nbsp%3Bto%26nbsp%3BExchange%26nbsp%3BOnline%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EConnect-ExchangeOnline%26nbsp%3B-Credential%26nbsp%3B%24UserCredential%26nbsp%3B-ShowProgress%26nbsp%3B%24true%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Another%26nbsp%3Bway%26nbsp%3Bto%26nbsp%3Bconnect%20(choose%20one%20or%20the%20other)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EConnect-ExchangeOnline%26nbsp%3B-UserPrincipalName%26nbsp%3Btom%40wechsler.onmicrosoft.com%26nbsp%3B-ShowProgress%26nbsp%3B%24true%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Specific%20information%20from%20a%20user%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-Mailbox%26nbsp%3B%E2%80%93Identity%26nbsp%3Btina.jackson%40tomwechsler.xyz%26nbsp%3B%7C%26nbsp%3BFormat-List%26nbsp%3BIdentity%2C%20ExchangeGUID%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Let's%26nbsp%3Bcheck%26nbsp%3Bthe%26nbsp%3Baccepted%26nbsp%3Bdomain%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-AcceptedDomain%26nbsp%3B%7C%26nbsp%3BFormat-List%26nbsp%3BDomainname%2C%26nbsp%3B*type*%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Check%26nbsp%3Bthe%26nbsp%3Blarge%26nbsp%3Baudience%26nbsp%3B(sender%26nbsp%3Badds%26nbsp%3Bdistribution%26nbsp%3Bgroup%26nbsp%3Bthat%26nbsp%3Bhas%26nbsp%3Bmore%26nbsp%3Bmembers%26nbsp%3Bthan%26nbsp%3Bthe%26nbsp%3Bconfigured%26nbsp%3Blarge%26nbsp%3Baudience%26nbsp%3Bsize%2C%26nbsp%3Bthey%26nbsp%3Bare%26nbsp%3Bshown%26nbsp%3Bthe%26nbsp%3BLarge%26nbsp%3BAudience%26nbsp%3BMailTip%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-OrganizationConfig%26nbsp%3B%7C%26nbsp%3BSelect-Object%26nbsp%3BMailTipsLargeAudienceThreshold%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23We%26nbsp%3Binvestigate%26nbsp%3Ba%26nbsp%3Bspecific%26nbsp%3Brole%26nbsp%3Bgroup%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-RoleGroup%26nbsp%3B%22Recipient%26nbsp%3BManagement%22%26nbsp%3B%7C%26nbsp%3BFormat-List%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23We%26nbsp%3Bexpand%26nbsp%3Bthe%26nbsp%3Broles%26nbsp%3Bproperty%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-RoleGroup%26nbsp%3B%22Recipient%26nbsp%3BManagement%22%26nbsp%3B%7C%26nbsp%3BSelect-Object%26nbsp%3B-ExpandProperty%26nbsp%3BRoles%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23View%26nbsp%3Bthe%26nbsp%3Bretention%26nbsp%3Bpolicy%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-RetentionPolicy%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Let's%26nbsp%3Blook%26nbsp%3Bat%26nbsp%3Bthe%26nbsp%3Bdefault%26nbsp%3Bpolicy%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-RetentionPolicy%26nbsp%3B-Identity%26nbsp%3B%22Default%26nbsp%3BMRM%26nbsp%3BPolicy%22%26nbsp%3B%7C%26nbsp%3BFormat-List%3C%2FSTRONG%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Closer%26nbsp%3Blook%26nbsp%3Bat%26nbsp%3Bthe%26nbsp%3Bretention%26nbsp%3Bpolicy%26nbsp%3Btag%26nbsp%3Blinks%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3EGet-RetentionPolicy%26nbsp%3B-Identity%26nbsp%3B%22Default%26nbsp%3BMRM%26nbsp%3BPolicy%22%26nbsp%3B%7C%26nbsp%3BSelect-Object%26nbsp%3B-ExpandProperty%26nbsp%3BRetentionPolicyTagLinks%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EYou%20have%20now%20successfully%20collected%20information%20in%20Exchange%20Online%20with%20PowerShell!%26nbsp%3BCongratulations!%3C%2FSPAN%3E%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%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1944569%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Contributor

 

Hi Microsoft 365 and Exchange Online friends,

 

I used the PowerShell ISE for this configuration. But you are also very welcome to use Visual Studio Code, just as you wish. Please start with the following steps to begin the deployment (the Hashtags are comments):

 

#The first two lines have nothing to do with the configuration, but make some space below in the blue part of the ISE

Set-Location C:\Temp
Clear-Host

 

#We need the module (without the parameter for a specific version)
Install-Module -Name ExchangeOnlineManagement -AllowClobber -Force -Verbose

#More specific if you want
Install-Module -Name ExchangeOnlineManagement -RequiredVersion 2.0.3 -AllowClobber -Force -Verbose

#Let's import the module
Import-Module ExchangeOnlineManagement

#Check the version (if you have not selected a version)
Get-InstalledModule -Name ExchangeOnlineManagement

#Variable for the credential
$UserCredential = Get-Credential

#Now we connect to Exchange Online
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true

#Another way to connect (choose one or the other)
Connect-ExchangeOnline -UserPrincipalName tom@wechsler.onmicrosoft.com -ShowProgress $true

#Specific information from a user
Get-Mailbox –Identity tina.jackson@tomwechsler.xyz | Format-List Identity, ExchangeGUID

#Let's check the accepted domain
Get-AcceptedDomain | Format-List Domainname, *type*

#Check the large audience (sender adds distribution group that has more members than the configured large audience size, they are shown the Large Audience MailTip
Get-OrganizationConfig | Select-Object MailTipsLargeAudienceThreshold

#We investigate a specific role group
Get-RoleGroup "Recipient Management" | Format-List

#We expand the roles property
Get-RoleGroup "Recipient Management" | Select-Object -ExpandProperty Roles

#View the retention policy
Get-RetentionPolicy

#Let's look at the default policy
Get-RetentionPolicy -Identity "Default MRM Policy" | Format-List

#Closer look at the retention policy tag links
Get-RetentionPolicy -Identity "Default MRM Policy" | Select-Object -ExpandProperty RetentionPolicyTagLinks
 
You have now successfully collected information in Exchange Online with PowerShell! Congratulations!
 

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