次の方法で共有


Grant-SCResource

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

Syntax

Default (Default)

Grant-SCResource
    [-VMMServer <ServerConnection>]
    -Resource <ClientObject>
    [-UserRoleName <String[]>]
    [-UserRoleID <Guid[]>]
    [-UserName <String>]
    [-JobGroup <Guid>]
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [-OnBehalfOfUser <String>]
    [-OnBehalfOfUserRole <UserRole>]
    [<CommonParameters>]

Description

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

Types of resources that you can share 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

Examples

Example 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.

Example 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.

Example 3: Share a resource with all members of a user role

PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "VMTemplate01"}
PS C:\> Grant-SCResource -Resource $Resource -UserRoleName "ContosoSelfServiceUsers"

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

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

Example 4: Share a resource with all members of a user role by using the user role ID

PS C:\> $Resource = Get-SCVMTemplate | where {$_.Name -eq "VMTemplate01"}
PS C:\> $UserRole = Get-SCUserRole -Name "ContosoSelfServiceUsers"
PS C:\> Grant-SCResource -Resource $Resource -UserRoleId $UserRole.Id

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

The second command gets the user role object named ContosoSelfServiceUsers and stores the object in the $UserRole variable.

The last command shares the resource stored in $Resource (VMTemplate01) with the members of user role ContosoSelfServiceUsers.

Parameters

-JobGroup

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.

Parameter properties

Type:Guid
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

-JobVariable

Specifies that job progress is tracked and stored in the variable named by this parameter.

Parameter properties

Type:String
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

-OnBehalfOfUser

Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.

Parameter properties

Type:String
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

-OnBehalfOfUserRole

Specifies a user role. To obtain a user role, use the Get-SCUserRole cmdlet. This cmdlet operates on behalf of the user role that this parameter specifies.

Parameter properties

Type:UserRole
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

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

Parameter properties

Type:Guid
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

-Resource

Specifies a resource object.

Parameter properties

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

Parameter sets

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

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

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

-UserName

Specifies a the name of a user. Enter a user name with the format Domain\User.

Parameter properties

Type:String
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

-UserRoleID

Specifies the ID of a user role.

Parameter properties

Type:

Guid[]

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

-UserRoleName

Specifies the name of a user role. Types of user roles that are named include Delegated Administrator, Read-Only Administrator, and Self-Service User.

Parameter properties

Type:

String[]

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

-VMMServer

Specifies a VMM server object.

Parameter properties

Type:ServerConnection
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

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.

Outputs

Resource

This cmdlet returns a Resource object.