Grant-SCResource
Applies To: System Center 2012 - Virtual Machine Manager
Grant-SCResource
Grants a user or self-service user role access to a resource.
Syntax
Parameter Set: Default
Grant-SCResource -Resource <ClientObject> [-JobGroup <Guid> ] [-JobVariable <String> ] [-PROTipID <Guid> ] [-RunAsynchronously] [-UserName <String> ] [-UserRoleName <String[]> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]
Detailed 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
-JobGroup<Guid>
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.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-JobVariable<String>
Specifies that job progress is tracked and stored in the variable named by this parameter.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-PROTipID<Guid>
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Resource<ClientObject>
Specifies a resource object.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-RunAsynchronously
Indicates that the job runs asynchronously so that control returns to the command shell immediately.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-UserName<String>
Specifies a the name of a user. Enter a user name with the format Domain\User.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-UserRoleName<String[]>
Specifies the name of a user role. Types of user roles that are named include Delegated Administrator, Read-Only Administrator and Self-Service User.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-VMMServer<ServerConnection>
Specifies a VMM server object.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
- Resource
Examples
1: Share a resource with a specific user.
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.
PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "Template01"}
PS C:\> Grant-SCResource "Resource $Resource "Username "Contoso\Katarina"
2: Share a resource with a user who is a member of multiple user roles.
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.
PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "Template01"}
PS C:\> Grant-SCResource -Resource $Resource -Username "Contoso\Katarina" -UserRoleName @("ContosoSelfServiceUsers", "SelfServiceUserRole02")
3: Share a resource with all members of a user role.
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.
PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "Template01"}
PS C:\> Grant-SCResource -Resource $Resource -UserRoleName "ContosoSelfServiceUsers"