---
title: Managing Mail-Enabled Security Groups with PowerShell
tags: [powershell, exchange, security-groups, office365, administration]
---

# Managing Mail-Enabled Security Groups with PowerShell

Mail-enabled security groups can be used to distribute messages as well as to grant access permissions to resources in Active Directory.

**Parent Topic:** [[programming/PowerShell/ExchangeOnline|PowerShell Exchange Online Commands]]
**Related:** [[programming/PowerShell/PowerShell|PowerShell Comprehensive Guide]]

## Prerequisites
Ensure you are connected to Exchange Online:
```powershell
Connect-ExchangeOnline
```

## Creating a Mail-Enabled Security Group
```powershell
New-DistributionGroup -Name "IT Security Team" `
                      -Alias "itsec" `
                      -PrimarySmtpAddress "itsec@yourdomain.com" `
                      -Type Security
```
*Note: The `New-DistributionGroup` cmdlet is used with the `-Type Security` parameter.*

## Managing Members

### Add a Member
```powershell
Add-DistributionGroupMember -Identity "IT Security Team" -Member "jdoe@yourdomain.com"
```

### Remove a Member
```powershell
Remove-DistributionGroupMember -Identity "IT Security Team" -Member "jdoe@yourdomain.com" -Confirm:$false
```

### Get Group Members
```powershell
Get-DistributionGroupMember -Identity "IT Security Team"
```

## Common Tasks

### Hiding from Global Address List (GAL)
```powershell
Set-DistributionGroup -Identity "IT Security Team" -HiddenFromAddressListsEnabled $true
```

---
Return to [[programming/PowerShell/ExchangeOnline|PowerShell Exchange Online Commands]]