

  

> Quick reference for Service Desk administration tasks.

  

---

  

# Exchange Online PowerShell

  

## Install Exchange Online Module

  

Run once:

  

```powershell

Install-Module ExchangeOnlineManagement -Scope CurrentUser

```

  

Verify installation:

  

```powershell

Get-Module ExchangeOnlineManagement -ListAvailable

```

  

---

  

# Enable PowerShell Script Execution

  

Check current policy:

  

```powershell

Get-ExecutionPolicy -List

```

  

Enable scripts for current user:

  

```powershell

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

```

  

Temporary bypass for current session:

  

```powershell

powershell.exe -ExecutionPolicy Bypass

```

  

---

  

# Connect to Exchange Online

  

Import module:

  

```powershell

Import-Module ExchangeOnlineManagement

```

  

Connect:

  

```powershell

Connect-ExchangeOnline

```

  

Connect with a specific account:

  

```powershell

Connect-ExchangeOnline -UserPrincipalName username@company.com

```

  

Verify connection:

  

```powershell

Get-ConnectionInformation

```

  

---

  

# Disconnect from Exchange Online

  

```powershell

Disconnect-ExchangeOnline -Confirm:$false

```

  

---

  

# Find Distribution Lists

  

## Search by partial name

  

```powershell

Get-DistributionGroup -Anr FSM

```

  

## Search Display Name

  

```powershell

Get-DistributionGroup -Filter "DisplayName -like '*FSM*'"

```

  

## Show more details

  

```powershell

Get-DistributionGroup -Filter "DisplayName -like '*FSM*'" |

Select Name,DisplayName,Alias,PrimarySmtpAddress

```

  

---

  

# Find Any Exchange Recipient

  

Search mailboxes, groups, contacts, shared mailboxes, etc.

  

```powershell

Get-Recipient -Filter "DisplayName -like '*FSM*'"

```

  

More details:

  

```powershell

Get-Recipient -Filter "DisplayName -like '*FSM*'" |

Select Name,RecipientType,PrimarySmtpAddress

```

  

---

  

# Find Shared Mailboxes

  

```powershell

Get-Mailbox -RecipientTypeDetails SharedMailbox

```

  

Search by name:

  

```powershell

Get-Mailbox -RecipientTypeDetails SharedMailbox |

Where-Object {$_.DisplayName -like "*FSM*"}

```

  

---

  

# View Distribution Group Members

  

By display name:

  

```powershell

Get-DistributionGroupMember -Identity "FSM"

```

  

By email address:

  

```powershell

Get-DistributionGroupMember -Identity "bdl@agas.com"

```

  

---

  

# Add User to Distribution List

  

```powershell

Add-DistributionGroupMember `

-Identity "FSM" `

-Member username

```

  

Example:

  

```powershell

Add-DistributionGroupMember `

-Identity "FSM" `

-Member jsmith

```

  

---

  

# Remove User from Distribution List

  

```powershell

Remove-DistributionGroupMember `

-Identity "FSM" `

-Member jsmith `

-Confirm:$false

```

  

---

  

# Find Distribution Group AD Object

  

Useful when Exchange name differs from AD name.

  

```powershell

Get-DistributionGroup "FSM" |

Format-List Name,DisplayName,Alias,DistinguishedName

```

  

---

  

# Active Directory User Management

  

## Load Active Directory Module

  

```powershell

Import-Module ActiveDirectory

```

  

---

  

# Find User

  

By username:

  

```powershell

Get-ADUser username

```

  

By display name:

  

```powershell

Get-ADUser -Filter 'Name -like "*John Smith*"'

```

  

---

  

# Disable Local/AD User

  

Disable AD account:

  

```powershell

Disable-ADAccount -Identity username

```

  

Verify:

  

```powershell

Get-ADUser username -Properties Enabled

```

  

---

  

# Enable Local/AD User

  

Enable AD account:

  

```powershell

Enable-ADAccount -Identity username

```

  

Verify:

  

```powershell

Get-ADUser username -Properties Enabled

```

  

---

  

# Reset Password

  

```powershell

Set-ADAccountPassword `

-Identity username `

-Reset `

-NewPassword (ConvertTo-SecureString "NewPassword123!" -AsPlainText -Force)

```

  

Force password change at next login:

  

```powershell

Set-ADUser username -ChangePasswordAtLogon $true

```

  

---

  

# Unlock AD Account

  

```powershell

Unlock-ADAccount username

```

  

Check lockout status:

  

```powershell

Get-ADUser username -Properties LockedOut

```

  

---

  

# AD Group Membership

  

## See User's Groups

  

```powershell

Get-ADPrincipalGroupMembership username |

Select Name

```

  

## Add User to Group

  

```powershell

Add-ADGroupMember `

-Identity "Group Name" `

-Members username

```

  

## Remove User from Group

  

```powershell

Remove-ADGroupMember `

-Identity "Group Name" `

-Members username `

-Confirm:$false

```

  

---

  

# Find Group by Name

  

```powershell

Get-ADGroup -Filter 'Name -like "*FSM*"'

```

  

---

  

# Find Group by Email Address

  

```powershell

Get-ADGroup `

-Filter 'mail -eq "bdl@agas.com"' `

-Properties mail

```

  

---

  

# Common Troubleshooting

  

## Exchange Module Won't Load

  

Check if installed:

  

```powershell

Get-Module ExchangeOnlineManagement -ListAvailable

```

  

Check execution policy:

  

```powershell

Get-ExecutionPolicy -List

```

  

Enable script execution:

  

```powershell

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

```

  

---

  

## Exchange Commands Hang

  

Test connection:

  

```powershell

Get-ConnectionInformation

```

  

Test response:

  

```powershell

Get-Mailbox -ResultSize 5

```

  

Avoid pulling everything:

  

✅ Faster

  

```powershell

Get-Recipient -Filter "DisplayName -like '*FSM*'"

```

  

❌ Slower

  

```powershell

Get-Recipient -ResultSize Unlimited |

Where-Object {$_.DisplayName -like "*FSM*"}

```

  

---

  

# Most Common Service Desk Commands

  

```powershell

Connect-ExchangeOnline

```

  

```powershell

Get-DistributionGroup -Anr FSM

```

  

```powershell

Get-DistributionGroupMember -Identity "FSM"

```

  

```powershell

Add-DistributionGroupMember -Identity "FSM" -Member username

```

  

```powershell

Remove-DistributionGroupMember -Identity "FSM" -Member username

```

  

```powershell

Enable-ADAccount username

```

  

```powershell

Disable-ADAccount username

```

  

```powershell

Unlock-ADAccount username

```

  

```powershell

Get-ADPrincipalGroupMembership username

```

  

```powershell

Disconnect-ExchangeOnline -Confirm:$false

```

  

---

**Last Updated:** 2026-06-24