Jaa


Get-MsolGroup

Updated: July 30, 2015

Applies To: Azure, Office 365, Windows Intune

Note



  • The cmdlets were previously known as the Microsoft Online Services Module for Windows PowerShell cmdlets.

The Get-MsolGroup cmdlet is used to retrieve groups from the connected tenant. This cmdlet can be used to return a single group, if ObjectId is passed in, or to search within all groups.

Syntax

Get-MsolGroup [-GroupType <string>] [-HasErrorsOnly] [-IsAgentRole] [-MaxResults <int>] [-SearchString <string>] [-TenantId <Guid>] [-UserObjectId <Guid>] [-UserPrincipalName <string>] [<CommonParameters>]

Parameters

    -All [<SwitchParameter>]
        If present then all results will be returned.  Cannot be used with 
        MaxResults parameter.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -GroupType <string>
        The filter to return only groups of the specified type. Valid values 
        are Security, MailEnabledSecurity, and DistributionList.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -HasErrorsOnly [<SwitchParameter>]
        The filter for only groups with validation errors.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -IsAgentRole [<SwitchParameter>]
        The filter for only agent groups. Used by partners only.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -MaxResults <int>
        The maximum number of results returned for a search. If not specified, 
        250 results will be returned.
        
        Required?                    false
        Position?                    named
        Default value                250
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -ObjectId <Guid>
        The unique ID of the group to retrieve.
        
        Required?                    true
        Position?                    named
        Default value                
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard characters?  false
        
    -SearchString <string>
        The string to search on. Only groups with a display name or email 
        address starting with this string will be returned.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -TenantId <Guid>
        The unique ID of the tenant to perform the operation on. If this is 
        not provided, then the value will default to the tenant of the current 
        user. This parameter is only applicable to partner users.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard characters?  false
        
    -UserObjectId <Guid>
        The unique ID of a user. If provided, only groups that this user 
        belongs to will be returned. This parameter must be used along with 
        IsAgentRole.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -UserPrincipalName <string>
        The user ID of a user. If provided, only groups that this user belongs 
        to will be returned. This must be used along with IsAgentRole.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        "get-help about_commonparameters".

Examples

The output is provided by Microsoft.Online.Administration.Group. The cmdlet returns a list of groups, which include the following information:

  • CommonName: The group's common name.

  • Description: A description of the group.

  • DisplayName: The group's display name.

  • EmailAddress: The group's email addresses. This is not returned for security groups.

  • Errors: A list of errors for the group.

  • GroupType: The group's type. Types can be SecuityGroup, Distributionlist or MailEnabledSecuirtyGroup.

  • IsSystem: Whether or not this group is a system group (created by ). These groups cannot be updated or removed.

  • LastDirSyncTime: The date and time that the group was last synched.

  • ObjectId: The group's unique object ID.

  • ValidationStatus: Whether or not the group has any errors.

Example 1

The following command returns the entire set of groups for the tenant (up to 250).

Get-MsolGroup

Example 2

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

Get-MsolGroup -isAgentRole -UserPrincipalName user@contoso.com

Example 3

The following command displays the information of the group that is specified by the GUID of the ObjectID in list format.

Get-MsolGroup -ObjectId fd65dbac-5c7a-4596-815f-e8457eb6173f | format-list

Example 4

The following command displays all the security groups in list format.

Get-MsolGroup -GroupType Security | format-list

Additional Resources

There are several other places you can get more information and help. These include:

See Also

Other Resources

Manage Azure Active Directory by using Windows PowerShell