Edit

Add-AzADGroupMember

Adds a user to an existing AD group.

Syntax

MemberObjectIdWithGroupObjectId (Default)

Add-AzADGroupMember
    -MemberObjectId <Guid[]>
    -TargetGroupObjectId <Guid>
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

MemberObjectIdWithGroupDisplayName

Add-AzADGroupMember
    -MemberObjectId <Guid[]>
    -TargetGroupDisplayName <String>
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

MemberObjectIdWithGroupObject

Add-AzADGroupMember
    -MemberObjectId <Guid[]>
    -TargetGroupObject <PSADGroup>
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

MemberUPNWithGroupDisplayNameParameterSet

Add-AzADGroupMember
    -MemberUserPrincipalName <String[]>
    -TargetGroupDisplayName <String>
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

MemberUPNWithGroupObjectParameterSet

Add-AzADGroupMember
    -MemberUserPrincipalName <String[]>
    -TargetGroupObject <PSADGroup>
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

MemberUPNWithGroupObjectIdParameterSet

Add-AzADGroupMember
    -MemberUserPrincipalName <String[]>
    -TargetGroupObjectId <Guid>
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Adds a user to an existing AD group.

Examples

Example 1 - Add a user to a group by object id

PS C:\> Add-AzADGroupMember -MemberObjectId 00001111-aaaa-2222-bbbb-3333cccc4444 -TargetGroupObjectId 00001111-aaaa-2222-bbbb-3333cccc4444

Adds the user with object id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' to the group with object id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb'.

Example 2 - Add a user to a group by piping

PS C:\> Get-AzADGroup -ObjectId aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb | Add-AzADGroupMember -MemberObjectId 00001111-aaaa-2222-bbbb-3333cccc4444

Gets the group with object id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' and pipes it to the Add-AzADGroupMember cmdlet to add the user to that group.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MemberObjectId

The object id of the member.

Parameter properties

Type:

Guid[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

MemberObjectIdWithGroupObjectId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
MemberObjectIdWithGroupDisplayName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
MemberObjectIdWithGroupObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MemberUserPrincipalName

The UPN of the member(s) to add to the group.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

MemberUPNWithGroupDisplayNameParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
MemberUPNWithGroupObjectParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
MemberUPNWithGroupObjectIdParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PassThru

Specifying this will return true if the command was successful.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TargetGroupDisplayName

The display name of the group to add the member(s) to.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

MemberObjectIdWithGroupDisplayName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
MemberUPNWithGroupDisplayNameParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TargetGroupObject

The object representation of the group to add the member(s) to.

Parameter properties

Type:PSADGroup
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

MemberObjectIdWithGroupObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False
MemberUPNWithGroupObjectParameterSet
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-TargetGroupObjectId

The object id of the group to add the member(s) to.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

MemberObjectIdWithGroupObjectId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
MemberUPNWithGroupObjectIdParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PSADGroup

Parameters: TargetGroupObject (ByValue)

Outputs

Boolean