< Back
Add-JCUserGroupMember
Post
NAME Add-JCUserGroupMember
SYNOPSIS
Adds a JumpCloud user to a JumpCloud User Group.
SYNTAX
Add-JCUserGroupMember [[-GroupName] <System.String>] [-ByID] [-GroupID <System.String>] -UserID <System.String>
[<CommonParameters>]
Add-JCUserGroupMember [-GroupName] <System.String> [-Username] <System.String> [<CommonParameters>]
DESCRIPTION
The Add-JCUserGroupMember function is used to add a JumpCloud user to a JumpCloud User Group. The new user can be
added by Username or by UserID.
PARAMETERS
-ByID <System.Management.Automation.SwitchParameter>
Use the -ByID parameter when either the UserID or GroupID is being passed over the pipeline to the
Add-JCUserGroupMember function. The -ByID SwitchParameter will set the ParameterSet to 'ByID' which will
increase the function speed and performance.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-GroupID <System.String>
The GroupID is used in the ParameterSet 'ByID'. The GroupID for a User Group can be found by running the
command:
PS C:\\> Get-JCGroup -type 'User'
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-GroupName <System.String>
The name of the JumpCloud User Group that you want to add the User to.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-UserID <System.String>
The _id of the User which you want to add to the User Group.
To find a JumpCloud UserID run the command:
PS C:\\> Get-JCUser | Select username, _id
The UserID will be the 24 character string populated for the _id field.
UserID has an Alias of _id. This means you can leverage the PowerShell pipeline to populate this field
automatically using the Get-JCUser function before calling Add-JCUserGroupMember. This is shown in EXAMPLES 2,
3, and 4.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Username <System.String>
The Username of the JumpCloud user you wish to add to the User Group.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
OUTPUTS
System.Object
NOTES
-------------------------- Example 1 --------------------------
PS C:\\> Add-JCUserGroupMember -Username cclemons -GroupName 'The Band'
Adds the JumpCloud user with Username 'cclemons' to the User Group 'The Band'
-------------------------- Example 2 --------------------------
PS C:\\> Get-JCUser | Where-Object sudo -EQ $true | Add-JCUserGroupMember -GroupName 'Administrators'
Adds all JumpCloud users where the 'sudo' attribute is equal to $true to the User Group 'Administrators'
-------------------------- Example 3 --------------------------
PS C:\\> Get-JCUser | Where-Object created -gt (Get-Date).AddDays(-7) | Add-JCUserGroupMember -GroupName 'New Hires'
Adds all JumpCloud users created within the last 7 days to the User Group 'New Hires'
-------------------------- Example 4 --------------------------
Get-JCUser | Select-Object username, @{name='Attribute Value'; expression={$_.attributes.value}} | Where-Object
'Attribute Value' -Like *Sales* | Add-JCUserGroupMember -GroupName Sales
Adds all JumpCloud users with a custom attribute value which contains 'Sales' to the JumpCloud User Group 'Sales'.
Note that to access the value of a nested property you must use Select-Object to access the nested property. In
this example a calculated property is also used.
RELATED LINKS
Online Version: https://github.com/TheJumpCloud/support ... roupMember
SYNOPSIS
Adds a JumpCloud user to a JumpCloud User Group.
SYNTAX
Add-JCUserGroupMember [[-GroupName] <System.String>] [-ByID] [-GroupID <System.String>] -UserID <System.String>
[<CommonParameters>]
Add-JCUserGroupMember [-GroupName] <System.String> [-Username] <System.String> [<CommonParameters>]
DESCRIPTION
The Add-JCUserGroupMember function is used to add a JumpCloud user to a JumpCloud User Group. The new user can be
added by Username or by UserID.
PARAMETERS
-ByID <System.Management.Automation.SwitchParameter>
Use the -ByID parameter when either the UserID or GroupID is being passed over the pipeline to the
Add-JCUserGroupMember function. The -ByID SwitchParameter will set the ParameterSet to 'ByID' which will
increase the function speed and performance.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-GroupID <System.String>
The GroupID is used in the ParameterSet 'ByID'. The GroupID for a User Group can be found by running the
command:
PS C:\\> Get-JCGroup -type 'User'
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-GroupName <System.String>
The name of the JumpCloud User Group that you want to add the User to.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-UserID <System.String>
The _id of the User which you want to add to the User Group.
To find a JumpCloud UserID run the command:
PS C:\\> Get-JCUser | Select username, _id
The UserID will be the 24 character string populated for the _id field.
UserID has an Alias of _id. This means you can leverage the PowerShell pipeline to populate this field
automatically using the Get-JCUser function before calling Add-JCUserGroupMember. This is shown in EXAMPLES 2,
3, and 4.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Username <System.String>
The Username of the JumpCloud user you wish to add to the User Group.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
OUTPUTS
System.Object
NOTES
-------------------------- Example 1 --------------------------
PS C:\\> Add-JCUserGroupMember -Username cclemons -GroupName 'The Band'
Adds the JumpCloud user with Username 'cclemons' to the User Group 'The Band'
-------------------------- Example 2 --------------------------
PS C:\\> Get-JCUser | Where-Object sudo -EQ $true | Add-JCUserGroupMember -GroupName 'Administrators'
Adds all JumpCloud users where the 'sudo' attribute is equal to $true to the User Group 'Administrators'
-------------------------- Example 3 --------------------------
PS C:\\> Get-JCUser | Where-Object created -gt (Get-Date).AddDays(-7) | Add-JCUserGroupMember -GroupName 'New Hires'
Adds all JumpCloud users created within the last 7 days to the User Group 'New Hires'
-------------------------- Example 4 --------------------------
Get-JCUser | Select-Object username, @{name='Attribute Value'; expression={$_.attributes.value}} | Where-Object
'Attribute Value' -Like *Sales* | Add-JCUserGroupMember -GroupName Sales
Adds all JumpCloud users with a custom attribute value which contains 'Sales' to the JumpCloud User Group 'Sales'.
Note that to access the value of a nested property you must use Select-Object to access the nested property. In
this example a calculated property is also used.
RELATED LINKS
Online Version: https://github.com/TheJumpCloud/support ... roupMember