Get-MgGroup

Get entity from groups by key

Syntax

Get-MgGroup
   [-ExpandProperty <String[]>]
   [-Property <String[]>]
   [-Filter <String>]
   [-Search <String>]
   [-Skip <Int32>]
   [-Sort <String[]>]
   [-Top <Int32>]
   [-ConsistencyLevel <String>]
   [-PageSize <Int32>]
   [-All]
   [-CountVariable <String>]
   [<CommonParameters>]
Get-MgGroup
   -GroupId <String>
   [-ExpandProperty <String[]>]
   [-Property <String[]>]
   [-ConsistencyLevel <String>]
   [<CommonParameters>]
Get-MgGroup
   -InputObject <IGroupsIdentity>
   [-ExpandProperty <String[]>]
   [-Property <String[]>]
   [-ConsistencyLevel <String>]
   [<CommonParameters>]

Description

Get entity from groups by key

Examples

Example 1: Get a list of groups

Connect-MgGraph -Scopes 'Group.Read.All'
Get-MgGroup | 
  Format-List Id, DisplayName, Description, GroupTypes

Id          : 0a1c8435-40a3-4a72-8586-e916c12b613a
DisplayName : Marketing
Description : A group to synthesize, analyze, and synchronize our marketing efforts.
GroupTypes  : {Unified}

Id          : a8fbb1b5-b994-4835-9183-c7421d149132
DisplayName : Business Development
Description : Welcome to the BizDev team.
GroupTypes  : {Unified}

This examples retrieves a list of groups.

To learn about other permissions for this resource, see the permissions reference.

To consent to any of these permissions run Connect-MgGraph -Scopes Permission. For example, Connect-MgGraph -Scopes GroupMember.Read.All, Group.Read.All.

Example 2: Get a group by the display name

Connect-MgGraph -Scopes 'Group.Read.All'
Get-MgGroup -Filter "DisplayName eq 'Business Development'" | 
  Format-List Id, DisplayName, Description, GroupTypes

Id          : a8fbb1b5-b994-4835-9183-c7421d149132
DisplayName : Business Development
Description : Welcome to the BizDev team.
GroupTypes  : {Unified}

This example gets a group by the specified display name.

To learn about other permissions for this resource, see the permissions reference.

To consent to any of these permissions run Connect-MgGraph -Scopes Permission. For example, Connect-MgGraph -Scopes GroupMember.Read.All, Group.Read.All.

Example 3: Get a count of all groups

Connect-MgGraph -Scopes 'Group.Read.All'
Get-MgGroup -ConsistencyLevel eventual -Count groupCount

Id                                   DisplayName          Description                                                            GroupTypes          AccessType
--                                   -----------          -----------                                                            ----------          ----------
0260d811-6674-4e65-9674-f511abcb4f7b Tailspin Toys Ltd                                                                           {}
0d5832d1-536d-4c5d-9435-e57413d9167f Test Group 1         This is a test group                                                   {}
0e06b38f-931a-47db-9a9a-60ab5f492005 Executives                                                                                  {}
1cb7317c-9c49-4dc8-a358-67ad8e95217c Finance Team                                                                                {}
2692d278-8323-4094-b286-e0ffce5e54a5 Marketing            A group to synthesize, analyze, and synchronize our marketing efforts. {Unified}
300a5486-9c58-422f-97a0-d2453977bcec Marketing resources  Marketing resources                                                    {}
4d5f57a1-85e0-41dd-8282-ff995ad5e1c3 Business Development Welcome to the BizDev team.                                            {Unified}

The example gets a list of all groups. The $groupCount variable contains the count of the objects in the result. Advanced query requires the ConsistencyLevel parameter set to eventual and the Count parameter in the command. For more information about ConsistencyLevel and Count, see Advanced query capabilities on Azure AD directory objects.

To learn about other permissions for this resource, see the permissions reference.

To consent to any of these permissions run Connect-MgGraph -Scopes Permission. For example, Connect-MgGraph -Scopes GroupMember.Read.All, Group.Read.All.

Example 4: Use -Search to get all the groups whose display name contains 'Market' including a count of the returned users

Connect-MgGraph -Scopes 'Group.Read.All'
Get-MgGroup -ConsistencyLevel eventual -Count groupCount -Search '"DisplayName:Market"'

Id                                   DisplayName         Description                                                            GroupTypes AccessType
--                                   -----------         -----------                                                            ---------- ----------
2692d278-8323-4094-b286-e0ffce5e54a5 Marketing           A group to synthesize, analyze, and synchronize our marketing efforts. {Unified}
300a5486-9c58-422f-97a0-d2453977bcec Marketing resources Marketing resources                                                    {}
74a7bfca-7fbc-4a67-b4bb-3ef115b114f1 Sales & Marketing   This is the sales and marketing team                                   {}

This example returns all groups whose display name contains 'Market'. The $groupCount variable contains the count of the objects in the result. Advanced query requires the ConsistencyLevel parameter set to eventual and the Count parameter in the command. For more information about ConsistencyLevel and Count, see Advanced query capabilities on Azure AD directory objects.

To learn about other permissions for this resource, see the permissions reference.

To consent to any of these permissions run Connect-MgGraph -Scopes Permission. For example, Connect-MgGraph -Scopes GroupMember.Read.All, Group.Read.All.

Example 5: Use -Filter to get all the applications with a display name that starts with 'A' including a count of the returned users, with the results ordered by display name

Connect-MgGraph -Scopes 'Group.Read.All'
Get-MgGroup -ConsistencyLevel eventual -Count groupCount -Filter "startsWith(DisplayName, 'A')" -OrderBy DisplayName

Id                                   DisplayName   Description                                           GroupTypes          AccessType
--                                   -----------   -----------                                           ----------          ----------
7fbcfd32-d930-4968-aa42-924bf462a305 All Company   This is the default group for everyone in the network {Unified}
f07a8d78-f18c-4c02-b339-9ebace025122 All Employees                                                       {}
bbfa9226-a965-47e1-9db2-bcfcb2c202e6 All Users

This example returns all groups whose display name starts with 'A'. The $groupCount variable contains the count of the objects in the result. Advanced query requires the ConsistencyLevel parameter set to eventual and the Count parameter in the command. For more information about ConsistencyLevel and Count, see Advanced query capabilities on Azure AD directory objects.

To learn about other permissions for this resource, see the permissions reference.

To consent to any of these permissions run Connect-MgGraph -Scopes Permission. For example, Connect-MgGraph -Scopes GroupMember.Read.All, Group.Read.All.

Parameters

-All

List all pages.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ConsistencyLevel

Indicates the requested consistency level. Documentation URL: https://developer.microsoft.com/en-us/office/blogs/microsoft-graph-advanced-queries-for-directory-objects-are-now-generally-available/

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-CountVariable

Specifies a count of the total number of items in a collection. By default, this variable will be set in the global scope.

Type:String
Aliases:CV
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ExpandProperty

Expand related entities

Type:String[]
Aliases:Expand
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Filter

Filter items by property values

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-GroupId

key: id of group

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

Identity Parameter To construct, please use Get-Help -Online and see NOTES section for INPUTOBJECT properties and create a hash table.

Type:IGroupsIdentity
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-PageSize

Sets the page size of results.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Property

Select properties to be returned

Type:String[]
Aliases:Select
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Search

Search items by search phrases

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Skip

Skip the first n items

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Sort

Order items by property values

Type:String[]
Aliases:OrderBy
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Top

Show only the first n items

Type:Int32
Aliases:Limit
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.Graph.PowerShell.Models.IGroupsIdentity

Outputs

Microsoft.Graph.PowerShell.Models.IMicrosoftGraphGroup1

Notes

ALIASES

COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

INPUTOBJECT : Identity Parameter

  • [AttachmentId <String>]: key: id of attachment
  • [ConversationId <String>]: key: id of conversation
  • [ConversationThreadId <String>]: key: id of conversationThread
  • [DirectorySettingId <String>]: key: id of directorySetting
  • [EndpointId <String>]: key: id of endpoint
  • [EventId <String>]: key: id of event
  • [ExtensionId <String>]: key: id of extension
  • [GroupId <String>]: key: id of group
  • [GroupLifecyclePolicyId <String>]: key: id of groupLifecyclePolicy
  • [IncludePersonalNotebooks <Boolean?>]: Usage: includePersonalNotebooks={includePersonalNotebooks}
  • [MentionId <String>]: key: id of mention
  • [MultiValueLegacyExtendedPropertyId <String>]: key: id of multiValueLegacyExtendedProperty
  • [NotebookId <String>]: key: id of notebook
  • [OnenotePageId <String>]: key: id of onenotePage
  • [OnenoteSectionId <String>]: key: id of onenoteSection
  • [PostId <String>]: key: id of post
  • [ProfilePhotoId <String>]: key: id of profilePhoto
  • [ResourceSpecificPermissionGrantId <String>]: key: id of resourceSpecificPermissionGrant
  • [SingleValueLegacyExtendedPropertyId <String>]: key: id of singleValueLegacyExtendedProperty
  • [User <String>]: Usage: User={User}
  • [UserId <String>]: key: id of user