Get-​Msol​Group

Gets groups from Azure Active Directory.

Syntax

Get-MsolGroup
   [-All]
   [-GroupType <GroupType>]
   [-HasErrorsOnly]
   [-IsAgentRole]
   [-SearchString <String>]
   [-TenantId <Guid>]
   [-UserObjectId <Guid>]
   [-UserPrincipalName <String>]
   [-HasLicenseErrorsOnly <Boolean>]
   [<CommonParameters>]
Get-MsolGroup
   [-GroupType <GroupType>]
   [-HasErrorsOnly]
   [-IsAgentRole]
   [-MaxResults <Int32>]
   [-SearchString <String>]
   [-TenantId <Guid>]
   [-UserObjectId <Guid>]
   [-UserPrincipalName <String>]
   [-HasLicenseErrorsOnly <Boolean>]
   [<CommonParameters>]
Get-MsolGroup
   -ObjectId <Guid>
   [-TenantId <Guid>]
   [<CommonParameters>]

Description

The Get-MsolGroup cmdlet gets groups from Azure Active Directory. This cmdlet can be used to return a single group, if you specify the ObjectId parameter, or to search within all groups.

Examples

Example 1: Get a group by using an ID

PS C:\> Get-MsolGroup -ObjectId af407072-7ae1-4b07-a0ca-6634b7396054

This command returns the group object that has the specified ID.

Example 2: Get all groups

PS C:\> Get-MsolGroup

This command returns the entire set of groups for the tenant, up to the default 250 results.

Example 3: Get a group by using a user principal name

PS C:\> Get-MsolGroup -isAgentRole -UserPrincipalName "pattifuller@contoso.com"

This command returns the agent groups that a user is a member of. This only applies for companies that have partner privileges.

Required Parameters

-All

Indicates that this cmdlet returns all results that it finds. Do not specify this parameter and the MaxResults parameter.

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

Specifies the unique object ID of the group to get.

Type:Guid
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-GroupType

Specifies the type of groups to get. Valid values are Security, MailEnabledSecurity, and DistributionList.

Type:GroupType
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-HasErrorsOnly

Indicates that this cmdlet returns only groups that have validation errors.

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

Specifies whether this cmdlet returns only security groups that have license errors.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-IsAgentRole

Specifies that this cmdlet returns only agent groups. This value applies only to partner users.

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

Specifies the maximum number of results that this cmdlet returns. The default value is 250.

Type:Int32
Position:Named
Default value:250
Accept pipeline input:False
Accept wildcard characters:False
-SearchString

Specifies a string. This cmdlet returns security groups that have a display name that start with this string.

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

Specifies the unique ID of the tenant on which to perform the operation. The default value is the tenant of the current user. This parameter applies only to partner users.

Type:Guid
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-UserObjectId

Specifies the unique ID of a user. This cmdlet returns security groups to which this user belongs. This parameter must be used along with the IsAgentRole parameter.

Type:Guid
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-UserPrincipalName

Specifies the user principal name of a user. This cmdlet returns security groups to which this user belongs. This parameter must be used along with the IsAgentRole parameter.

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

Outputs

Microsoft.Online.Administration.Group