Skip to main content

Group helpers

Requires EXO (for DGs/role groups) and Microsoft Graph for M365 groups where applicable. For complete, up-to-date info, run Get-Help <FunctionName> -Detailed.

Add-EntraGroupDevice

Add one or more devices to an Entra group (Graph scopes: Group.ReadWrite.All, Directory.Read.All).

Syntax

Add-EntraGroupDevice [-GroupName <String>] [-GroupId <String>] -DeviceIdentifier <String[]> [-TreatInputAsId] [-PassThru]
ParameterDescriptionRequiredDefault
GroupNameTarget group display name.Yes*-
GroupIdTarget group object ID (use instead of GroupName).Yes*-
DeviceIdentifierDevice display name or object ID. Pipeline accepted.Yes-
TreatInputAsIdTreat every DeviceIdentifier as an object ID (skip name lookup).NoFalse
PassThruEmit a status object per device.NoFalse

*Use either GroupName or GroupId.

Examples

"PC1","PC2" | Add-EntraGroupDevice -GroupName "Zero Trust Devices"
Add-EntraGroupDevice -GroupId "00000000-0000-0000-0000-000000000000" -DeviceIdentifier "PC1" -PassThru

Add-EntraGroupUser

Add one or more users to an Entra group (Graph scopes: Group.ReadWrite.All, Directory.Read.All).

Syntax

Add-EntraGroupUser [-GroupName <String>] [-GroupId <String>] -UserIdentifier <String[]> [-TreatInputAsId] [-PassThru]
ParameterDescriptionRequiredDefault
GroupNameTarget group display name.Yes*-
GroupIdTarget group object ID (use instead of GroupName).Yes*-
UserIdentifierUPN/display name/object ID. Pipeline accepted.Yes-
TreatInputAsIdTreat every UserIdentifier as an object ID (skip name lookup).NoFalse
PassThruEmit a status object per user.NoFalse

*Use either GroupName or GroupId.

Examples

"user1@contoso.com","user2@contoso.com" | Add-EntraGroupUser -GroupName "Project Team"
Add-EntraGroupUser -GroupId "00000000-0000-0000-0000-000000000000" -UserIdentifier "user1@contoso.com" -PassThru

Export-DistributionGroups

Export distribution groups and members.

Syntax

Export-DistributionGroups [-DistributionGroup <String[]>] [-Csv] [-CsvFolder <String>]
ParameterDescriptionRequiredDefault
DistributionGroupGroup identity (name/alias/SMTP). Pipeline accepted.NoAll DGs
CsvForce CSV export.NoFalse
CsvFolderDestination for CSV.NoCurrent directory

Example

Export-DistributionGroups -DistributionGroup "IT Team" -CsvFolder 'C:\Temp\DGs'

Export-DynamicDistributionGroups

Export dynamic DGs and evaluated members.

Syntax

Export-DynamicDistributionGroups [-DynamicDistributionGroup <String[]>] [-Csv] [-CsvFolder <String>]
ParameterDescriptionRequiredDefault
DynamicDistributionGroupDynamic DG identity. Pipeline accepted.NoAll dynamic DGs
CsvForce CSV export.NoFalse
CsvFolderDestination for CSV.NoCurrent directory

Example

Export-DynamicDistributionGroups -CsvFolder 'C:\Temp\DynDGs'

Export-M365Group

Export Microsoft 365 groups (members/owners).

Syntax

Export-M365Group [-M365Group <String[]>] [-Csv] [-CsvFolder <String>]
ParameterDescriptionRequiredDefault
M365GroupGroup identity (name/alias/SMTP). Pipeline accepted.NoAll M365 groups
CsvForce CSV export.NoFalse
CsvFolderDestination for CSV.NoCurrent directory

Example

Export-M365Group -M365Group "Project A" -CsvFolder 'C:\Temp\M365'

Get-DynamicDistributionGroupFilter

Show the simplified filter of a dynamic distribution group.

Syntax

Get-DynamicDistributionGroupFilter -DynamicDistributionGroup <String> [-IncludeDefaults] [-AsObject]
ParameterDescriptionRequired
DynamicDistributionGroupDynamic DG identity. Pipeline accepted.Yes
IncludeDefaultsInclude default EXO filter clauses.No
AsObjectReturn as object instead of string.No

Example

Get-DynamicDistributionGroupFilter -DynamicDistributionGroup "All Mailboxes"

Get-EntraGroupDevice

Show the Entra groups a device belongs to (Graph scopes: Group.Read.All, Directory.Read.All).

Syntax

Get-EntraGroupDevice -DeviceIdentifier <String> [-TreatInputAsId] [-GridView]
ParameterDescriptionRequiredDefault
DeviceIdentifierDevice display name or object ID. Pipeline accepted.Yes-
TreatInputAsIdTreat the DeviceIdentifier as an object ID (skip name lookup).NoFalse
GridViewShow details in Out-GridView.NoFalse

Examples

Get-EntraGroupDevice -DeviceIdentifier "PC123"
"00000000-0000-0000-0000-000000000000" | Get-EntraGroupDevice -TreatInputAsId -GridView

Get-EntraGroupUser

Show the Entra groups a user belongs to (Graph scopes: Group.Read.All, Directory.Read.All).

Syntax

Get-EntraGroupUser -UserIdentifier <String> [-TreatInputAsId] [-GridView]
ParameterDescriptionRequiredDefault
UserIdentifierUPN/display name/object ID. Pipeline accepted.Yes-
TreatInputAsIdTreat the UserIdentifier as an object ID (skip name lookup).NoFalse
GridViewShow details in Out-GridView.NoFalse

Examples

Get-EntraGroupUser -UserIdentifier "user@contoso.com"
"00000000-0000-0000-0000-000000000000" | Get-EntraGroupUser -TreatInputAsId -GridView

Get-EntraGroupMembers

Show the members of an Entra group (users, devices, and other directory objects) (Graph scopes: Group.Read.All, Directory.Read.All).

Syntax

Get-EntraGroupMembers [-GroupName <String>] [-GroupId <String>] [-IncludeDeviceUsers] [-GridView]
ParameterDescriptionRequiredDefault
GroupNameTarget group display name. Pipeline accepted.Yes*-
GroupIdTarget group object ID (use instead of GroupName).Yes*-
IncludeDeviceUsersWhen members are devices, resolve registered owners and users.NoFalse
GridViewShow details in Out-GridView.NoFalse

*Use either GroupName or GroupId.

Examples

Get-EntraGroupMembers "intune - app - netterm"
"intune - app - netterm" | Get-EntraGroupMembers
Get-EntraGroupMembers -GroupId "00000000-0000-0000-0000-000000000000" -GridView
Get-EntraGroupMembers "intune - app - netterm" -IncludeDeviceUsers
note
  • When -IncludeDeviceUsers is used and the member is a device, the output includes a Device Owners/Users column.
  • If owners and users are identical, the list is shown once; otherwise owners and users are combined in the same column.

Get-RoleGroupsMembers

List Exchange Online role groups and members.

Syntax

Get-RoleGroupsMembers [-AsTable] [-GridView]
ParameterDescriptionRequiredDefault
AsTableShow formatted table output.NoFalse (objects)
GridViewShow results in Out-GridView.NoFalse

Example

Get-RoleGroupsMembers -AsTable

Get-UserGroups

Show the groups (DGs/M365) a user/contact/group belongs to.

Syntax

Get-UserGroups -UserPrincipalName <String> [-GridView]
ParameterDescriptionRequiredDefault
UserPrincipalNameUser/contact/group identity.Yes-
GridViewShow details in Out-GridView.NoFalse

Example

Get-UserGroups -UserPrincipalName 'user@contoso.com'

Remove-EntraGroupDevice

Remove one or more devices from an Entra group (Graph scopes: Group.ReadWrite.All, Directory.Read.All).

Syntax

Remove-EntraGroupDevice [-GroupName <String>] [-GroupId <String>] -DeviceIdentifier <String[]> [-TreatInputAsId] [-PassThru]
Remove-EntraGroupDevice [-GroupName <String>] [-GroupId <String>] -ClearAll [-PassThru]
ParameterDescriptionRequiredDefault
GroupNameTarget group display name.Yes*-
GroupIdTarget group object ID (use instead of GroupName).Yes*-
DeviceIdentifierDevice display name or object ID. Pipeline accepted.Yes-
TreatInputAsIdTreat every DeviceIdentifier as an object ID (skip name lookup).NoFalse
ClearAllRemove all device members from the group (users and other objects are not removed). Prompts for confirmation.NoFalse
PassThruEmit a status object per device.NoFalse

*Use either GroupName or GroupId.

Examples

"PC1","PC2" | Remove-EntraGroupDevice -GroupName "Zero Trust Devices"
Remove-EntraGroupDevice -GroupId "00000000-0000-0000-0000-000000000000" -DeviceIdentifier "PC1" -PassThru
Remove-EntraGroupDevice -GroupName "Zero Trust Devices" -ClearAll
Remove-EntraGroupDevice -GroupName "Zero Trust Devices" -ClearAll -WhatIf

Remove-EntraGroupUser

Remove one or more users from an Entra group (Graph scopes: Group.ReadWrite.All, Directory.Read.All).

Syntax

Remove-EntraGroupUser [-GroupName <String>] [-GroupId <String>] -UserIdentifier <String[]> [-TreatInputAsId] [-PassThru]
Remove-EntraGroupUser [-GroupName <String>] [-GroupId <String>] -ClearAll [-PassThru]
ParameterDescriptionRequiredDefault
GroupNameTarget group display name.Yes*-
GroupIdTarget group object ID (use instead of GroupName).Yes*-
UserIdentifierUPN/display name/object ID. Pipeline accepted.Yes-
TreatInputAsIdTreat every UserIdentifier as an object ID (skip name lookup).NoFalse
ClearAllRemove all user members from the group (devices and other objects are not removed). Prompts for confirmation.NoFalse
PassThruEmit a status object per user.NoFalse

*Use either GroupName or GroupId.

Examples

"user1@contoso.com","user2@contoso.com" | Remove-EntraGroupUser -GroupName "Project Team"
Remove-EntraGroupUser -GroupId "00000000-0000-0000-0000-000000000000" -UserIdentifier "user1@contoso.com" -PassThru
Remove-EntraGroupUser -GroupName "Project Team" -ClearAll
Remove-EntraGroupUser -GroupName "Project Team" -ClearAll -WhatIf

Search-EntraGroup

Find Entra groups by display name and/or description (Graph scopes: Group.Read.All, Directory.Read.All).

Syntax

Search-EntraGroup -SearchText <String> [-SearchIn <String>] [-GridView]
ParameterDescriptionRequiredDefault
SearchTextText to search in display name and/or description. Pipeline accepted.Yes-
SearchInSearch target: DisplayName, Description, Any.NoDisplayName
GridViewShow details in Out-GridView.NoFalse

Examples

Search-EntraGroup -SearchText "java"
Search-EntraGroup -SearchText "jre"
Search-EntraGroup -SearchText "legacy apps" -SearchIn Description
"marketing" | Search-EntraGroup -SearchIn Any -GridView