DEV Community

Ranjit Rimal
Ranjit Rimal

Posted on

PowerShell Script to Retrieve baseline configuration for Exchange Online

Guys,
Here's a PowerShell script that gathers a baseline configuration for Exchange Online tenants. This script connects to Exchange Online and retrieves various settings, such as organization configuration, mailbox policies, transport rules, and more. You can use this as a starting point and customize it based on the specific configurations you're looking to baseline.

There are two versions on messaging - Exchange Online Plan 1 provides a 50 GB mailbox, supports messages up to 150 MB, and includes Outlook on the web for a premium browser-based experience. Exchange Online Plan 2 includes everything in Plan 1, plus a 100 GB mailbox, built-in data loss prevention (DLP), and cloud voicemail services with call answering and automated attendant

Connect to Exchange Online

Connect-ExchangeOnline -UserPrincipalName admin@yourte nant.onmicrosoft.com

Retrieve Organization Configuration

$orgConfig = Get-OrganizationConfig
$orgConfig | Format-List

Retrieve Accepted Domains

$acceptedDomains = Get-AcceptedDomain
$acceptedDomains | Format-Table Name, DomainType

Retrieve Mailbox Policies

$mailboxPolicies = Get-OwaMailboxPolicy
$mailboxPolicies | Format-Table Name, AllowFileAttachments, DefaultTheme

Retrieve Transport Rules

$transportRules = Get-TransportRule
$transportRules | Format-Table Name, Enabled, Mode

Retrieve Mobile Device Policies

$mobileDevicePolicies = Get-MobileDeviceMailboxPolicy
$mobileDevicePolicies | Format-Table Name, AllowBluetooth, RequireEncryption

Retrieve Mail Flow Rules

$mailFlowRules = Get-MailFlowRule
$mailFlowRules | Format-Table Name, Enabled

Retrieve Exchange Online Protection (EOP) Settings

$antispamSettings = Get-HostedContentFilterPolicy
$antispamSettings | Format-Table Name, SpamAction, QuarantineRetentionPeriod

Retrieve Mailbox Quotas

$mailboxQuotas = Get-Mailbox | Select-Object DisplayName, ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota
$mailboxQuotas | Format-Table DisplayName, ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota

Disconnect from Exchange Online

Disconnect-ExchangeOnline -Confirm:$false

Save this script to the ps1 file and run it save report in txt or csv file. Make sure to replace admin@your tenant.onmicrosoft.com with your actual administrator account. This script will provide a snapshot of your tenant’s configuration, which can be useful for auditing, troubleshooting, or establishing a baseline!

Top comments (0)