編輯

共用方式為


New-AzStorageLocalUserPermissionScope

Creates a permission scope object, which can be used in Set-AzStorageLocalUser.

Syntax

New-AzStorageLocalUserPermissionScope
   -Permission <String>
   -Service <String>
   -ResourceName <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzStorageLocalUserPermissionScope cmdlet creates a permission scope object, which can be used in Set-AzStorageLocalUser.

Examples

Example 1: Create permission scope objects, then create or update local user with the permission scope objects.

$permissionScope1 = New-AzStorageLocalUserPermissionScope -Permission rw -Service blob -ResourceName container1 

$permissionScope2 = New-AzStorageLocalUserPermissionScope -Permission rwd -Service file -ResourceName share2

$localuser = Set-AzStorageLocalUser -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -UserName testuser1 -HomeDirectory "/" -PermissionScope $permissionScope1,$permissionScope2

$localuser

   ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount

Name      Sid                                          HomeDirectory HasSharedKey HasSshKey HasSshPassword PermissionScopes SshAuthorizedKeys
----      ---                                          ------------- ------------ --------- -------------- ---------------- -----------------
testuser1 S-1-2-0-0000000000-000000000-0000000000-0000 /                                                   [container1,...]                  

$localuser.PermissionScopes

Permissions Service ResourceName
----------- ------- ------------
rw          blob    container1  
rwd         file    share2

This first 2 commands create 2 permission scope objects. The following commands create or update a local user with the permission scope objects, then show the updated local user properties.

Parameters

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Permission

Specify the permissions for the local user. Possible values include: Read(r), Write (w), Delete (d), List (l), and Create (c).

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceName

Specify the name of resource, normally the container name or the file share name, used by the local user.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Service

Specify the service used by the local user, e.g. blob, file.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

PSPermissionScope