< Back
Add-CrmSecurityRoleToUser
Post
NAME Add-CrmSecurityRoleToUser
SYNOPSIS
Assigns a security role to a user.
SYNTAX
Add-CrmSecurityRoleToUser [-conn <CrmServiceClient>] [-UserRecord] <PSObject> [[-SecurityRoleRecord] <PSObject>]
[[-SecurityRoleName] <String>] [<CommonParameters>]
Add-CrmSecurityRoleToUser [-conn <CrmServiceClient>] [-UserId] <String> [[-SecurityRoleId] <String>]
[[-SecurityRoleName] <String>] [<CommonParameters>]
DESCRIPTION
The Add-CrmSecurityRoleToUser cmdlet lets you assign a security role to a user.
There are two ways to specify records.
1. Pass record's Id for both records.
2. Get a record object by using Get-CrmRecord/Get-CrmRecords cmdlets, and pass it for both records.
PARAMETERS
-conn <CrmServiceClient>
A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UserRecord <PSObject>
A user record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord, then you
don't use UserId.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SecurityRoleRecord <PSObject>
A security role record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord,
then you don't use SecurityRoleId.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SecurityRoleName <String>
A name of security role record
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UserId <String>
An Id (guid) of user record
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SecurityRoleId <String>
An Id (guid) of security role record
Required? false
Position? 2
Default value
Accept pipeline input? false
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
OUTPUTS
NOTES
-------------------------- Example 1 --------------------------
Add-CrmSecurityRoleToUser -conn $conn -UserId 00005a70-6317-e511-80da-c4346bc43d94 -SecurityRoleId
66005a70-6317-e511-80da-c4346bc43d94
This example assigns the security role to the user by using Id.
-------------------------- Example 2 --------------------------
Add-CrmSecurityRoleToUser 00005a70-6317-e511-80da-c4346bc43d94 66005a70-6317-e511-80da-c4346bc43d94
This example assigns the security role to the user by using Id by omitting parameters names.
When omitting parameter names, you do not provide $conn, cmdlets automatically finds it.
-------------------------- Example 3 --------------------------
PS C:\\>$user = Get-CrmRecord sysetmuser 00005a70-6317-e511-80da-c4346bc43d94 fullname
PS C:\\>$role = Get-CrmRecord role 66005a70-6317-e511-80da-c4346bc43d94 name
PS C:\\>Add-CrmSecurityRoleToUser $user $role
This example assigns the security role to the user by using record objects.
-------------------------- Example 4 --------------------------
Add-CrmSecurityRoleToUser -conn $conn -UserId 00005a70-6317-e511-80da-c4346bc43d94 -SecurityRoleName "salesperson"
This example assigns the salesperson role to the user by using Id and role name.
RELATED LINKS
SYNOPSIS
Assigns a security role to a user.
SYNTAX
Add-CrmSecurityRoleToUser [-conn <CrmServiceClient>] [-UserRecord] <PSObject> [[-SecurityRoleRecord] <PSObject>]
[[-SecurityRoleName] <String>] [<CommonParameters>]
Add-CrmSecurityRoleToUser [-conn <CrmServiceClient>] [-UserId] <String> [[-SecurityRoleId] <String>]
[[-SecurityRoleName] <String>] [<CommonParameters>]
DESCRIPTION
The Add-CrmSecurityRoleToUser cmdlet lets you assign a security role to a user.
There are two ways to specify records.
1. Pass record's Id for both records.
2. Get a record object by using Get-CrmRecord/Get-CrmRecords cmdlets, and pass it for both records.
PARAMETERS
-conn <CrmServiceClient>
A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UserRecord <PSObject>
A user record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord, then you
don't use UserId.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SecurityRoleRecord <PSObject>
A security role record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord,
then you don't use SecurityRoleId.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SecurityRoleName <String>
A name of security role record
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UserId <String>
An Id (guid) of user record
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SecurityRoleId <String>
An Id (guid) of security role record
Required? false
Position? 2
Default value
Accept pipeline input? false
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
OUTPUTS
NOTES
-------------------------- Example 1 --------------------------
Add-CrmSecurityRoleToUser -conn $conn -UserId 00005a70-6317-e511-80da-c4346bc43d94 -SecurityRoleId
66005a70-6317-e511-80da-c4346bc43d94
This example assigns the security role to the user by using Id.
-------------------------- Example 2 --------------------------
Add-CrmSecurityRoleToUser 00005a70-6317-e511-80da-c4346bc43d94 66005a70-6317-e511-80da-c4346bc43d94
This example assigns the security role to the user by using Id by omitting parameters names.
When omitting parameter names, you do not provide $conn, cmdlets automatically finds it.
-------------------------- Example 3 --------------------------
PS C:\\>$user = Get-CrmRecord sysetmuser 00005a70-6317-e511-80da-c4346bc43d94 fullname
PS C:\\>$role = Get-CrmRecord role 66005a70-6317-e511-80da-c4346bc43d94 name
PS C:\\>Add-CrmSecurityRoleToUser $user $role
This example assigns the security role to the user by using record objects.
-------------------------- Example 4 --------------------------
Add-CrmSecurityRoleToUser -conn $conn -UserId 00005a70-6317-e511-80da-c4346bc43d94 -SecurityRoleName "salesperson"
This example assigns the salesperson role to the user by using Id and role name.
RELATED LINKS