Skip to content

Instantly share code, notes, and snippets.

@andrewpayne68
Last active October 19, 2025 11:10
Show Gist options
  • Select an option

  • Save andrewpayne68/6db87afb1329ccaa3e7b7d60666b58d9 to your computer and use it in GitHub Desktop.

Select an option

Save andrewpayne68/6db87afb1329ccaa3e7b7d60666b58d9 to your computer and use it in GitHub Desktop.
Manage MS 365 Exchange via PowerShell

Manage MS 365 Exchange via PowerShell (must be run as local admin).

Perform these commands once:

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

Install-Module -Name ExchangeOnlineManagement

Import-Module ExchangeOnlineManagement

Then whenever you want to connect:

Connect-ExchangeOnline

Example

PowerShell script example to obtain which mailboxes User Bill Smith has access to:

get-Mailbox -Resultsize Unlimited | Get-MailboxPermission -User bill.smith | ? {$_.AccessRights -match "FullAccess" -and $_.IsInherited -eq $False}  | get-mailbox | select identity,primarysmtpaddress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment