Grant-SCResource

Grants a user or self-service user role access to a resource.

Description

The Grant-SCResource cmdlet grants a user or self-service user role access to a resource.

Types of resources that can be shared using Grant-SCResource include the following: 

- Service Templates
- Virtual Machine Templates
- Guest Operating System Profiles
- SQL Server Profiles
- Hardware Profiles
- Application Profiles
 - Services
- Virtual Machines

For more information about Grant-SCResource, type: "Get-Help Grant-SCResource -online".

Parameters

Resource

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a resource object.

JobGroup

Required? false
Accept Pipeline Input? false
Position? named
Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identifier runs. 

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

UserName

Required? false
Accept Pipeline Input? false
Position? named
Specifies a the name of a user. Enter a user name with the format Domain\User.

UserRoleName

Required? false
Accept Pipeline Input? false
Position? named
Specifies the name of a user role. Types of user roles that are named include Delegated Administrator, Read-Only Administrator and Self-Service User.

VMMServer

Required? false
Accept Pipeline Input? false
Position? named
Specifies a VMM server object.

Examples

1: Share a resource with a specific user.
PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "Template01"}
PS C:\> Grant-SCResource –Resource $Resource –Username “Contoso\Katarina” 

The first command gets the template object named Template01 and stores the object in the $Resource variable.

The second command shares the resource stored in $Resource (Template01) with the user named Katarina. If the user is a member of multiple self-service user roles with receive permission, then a user role must be specified.
2: Share a resource with a user who is a member of multiple user roles.
PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "Template01"}
PS C:\> Grant-SCResource -Resource $Resource -Username “Contoso\Katarina” -UserRoleName @("ContosoSelfServiceUsers", "SelfServiceUserRole02")
The first command gets the template object named Template01 and stores the object in the $Resource variable.

The second command shares the resource stored in $Resource (Template01) with the user named Katarina but only while that user is using the ContosoSelfServiceUsers or SelfServiceUserRole02 user roles.
3: Share a resource with all members of a user role.
PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "Template01"}
PS C:\> Grant-SCResource -Resource $Resource -UserRoleName "ContosoSelfServiceUsers"
The first command gets the template object named Template01 and stores the object in the $Resource variable.

The second command shares the resource stored in $Resource (Template01) with the members of the user role named ContosoSelfServiceUsers.

See Also