你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Update-AzDataLakeGen2Item

更新属性、元数据、权限、ACL 和所有者上的文件或目录。

语法

ReceiveManual (默认值)

Update-AzDataLakeGen2Item
    [-FileSystem] <String>
    [-Path <String>]
    [-Permission <String>]
    [-Owner <String>]
    [-Group <String>]
    [-Property <Hashtable>]
    [-Metadata <Hashtable>]
    [-Acl <PSPathAccessControlEntry[]>]
    [-Context <IStorageContext>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ItemPipeline

Update-AzDataLakeGen2Item
    -InputObject <AzureDataLakeGen2Item>
    [-Permission <String>]
    [-Owner <String>]
    [-Group <String>]
    [-Property <Hashtable>]
    [-Metadata <Hashtable>]
    [-Acl <PSPathAccessControlEntry[]>]
    [-Context <IStorageContext>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

Update-AzDataLakeGen2Item cmdlet 更新属性、元数据、权限、ACL 和所有者上的文件或目录。 仅当为存储帐户启用了分层命名空间时,此 cmdlet 才有效。 可以使用“-EnableHierarchicalNamespace $true”运行“New-AzStorageAccount”cmdlet 来创建此类帐户。

示例

示例 1:使用 3 个 ACL 条目创建 ACL 对象,并将 ACL 以递归方式更新到文件系统中的所有项

$acl = Set-AzDataLakeGen2ItemAclObject -AccessControlType user -Permission rwx
$acl = Set-AzDataLakeGen2ItemAclObject -AccessControlType group -Permission rw- -InputObject $acl
$acl = Set-AzDataLakeGen2ItemAclObject -AccessControlType other -Permission "rwt" -InputObject $acl
Get-AzDataLakeGen2ChildItem -FileSystem "filesystem1" -Recurse | Update-AzDataLakeGen2Item -ACL $acl
FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group
----                 -----------  ------          ------------         -----------  -----                -----
dir1                 True                         2020-03-13 13:07:34Z rwxrw-rwt    $superuser           $superuser
dir1/file1           False        1024            2020-03-23 09:29:18Z rwxrw-rwt    $superuser           $superuser
dir2                 True                         2020-03-23 09:28:36Z rwxrw-rwt    $superuser           $superuser

此命令首先创建包含 3 acl 条目的 ACL 对象(使用 -InputObject 参数将 acl 条目添加到现有 acl 对象),然后获取文件系统中的所有项并更新项上的 acl。

示例 2:更新文件上的所有属性,并显示它们

$file = Update-AzDataLakeGen2Item -FileSystem "filesystem1" -Path "dir1/file1" `
                 -Acl $acl `
                 -Property @{"ContentType" = "image/jpeg"; "ContentMD5" = "i727sP7HigloQDsqadNLHw=="; "ContentEncoding" = "UDF8"; "CacheControl" = "READ"; "ContentDisposition" = "True"; "ContentLanguage" = "EN-US"} `
                 -Metadata  @{"tag1" = "value1"; "tag2" = "value2" } `
                 -Permission rw-rw-rwx `
                 -Owner '$superuser' `
                 -Group '$superuser'

$file

   FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group
----                 -----------  ------          ------------         -----------  -----                -----
dir1/file1           False        1024            2020-03-23 09:57:33Z rwxrw-rw-    $superuser           $superuser

$file.ACL

DefaultScope AccessControlType EntityId Permissions
------------ ----------------- -------- -----------
False        User                       rwx
False        Group                      rw-
False        Other                      rw-

$file.Permissions

Owner        : Execute, Write, Read
Group        : Write, Read
Other        : Write, Read
StickyBit    : False
ExtendedAcls : False

$file.Properties.Metadata

Key  Value
---  -----
tag2 value2
tag1 value1

$file.Properties


LastModified          : 3/23/2020 9:57:33 AM +00:00
CreatedOn             : 3/23/2020 9:29:18 AM +00:00
Metadata              : {[tag2, value2], [tag1, value1]}
CopyCompletedOn       : 1/1/0001 12:00:00 AM +00:00
CopyStatusDescription :
CopyId                :
CopyProgress          :
CopySource            :
CopyStatus            : Pending
IsIncrementalCopy     : False
LeaseDuration         : Infinite
LeaseState            : Available
LeaseStatus           : Unlocked
ContentLength         : 1024
ContentType           : image/jpeg
ETag                  : "0x8D7CF109B9878CC"
ContentHash           : {139, 189, 187, 176...}
ContentEncoding       : UDF8
ContentDisposition    : True
ContentLanguage       : EN-US
CacheControl          : READ
AcceptRanges          : bytes
IsServerEncrypted     : True
EncryptionKeySha256   :
AccessTier            : Cool
ArchiveStatus         :
AccessTierChangedOn   : 1/1/0001 12:00:00 AM +00:00

此命令更新文件的所有属性(ACL、权限、所有者、组、元数据、属性都可以使用任意组合进行更新),并在 Powershell 控制台中显示它们。

示例 3:向目录添加 ACL 条目

## Get the origin ACL
$acl = (Get-AzDataLakeGen2Item -FileSystem "filesystem1" -Path 'dir1/dir3/').ACL

# Update permission of a new ACL entry (if ACL entry with same AccessControlType/EntityId/DefaultScope not exist, will add a new ACL entry, else update permission of existing ACL entry)
$acl = Set-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityId $id -Permission rw- -InputObject $acl

# set the new acl to the directory
Update-AzDataLakeGen2Item -FileSystem "filesystem1" -Path 'dir1/dir3/' -ACL $acl
FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group
----                 -----------  ------          ------------         -----------  -----                -----
dir1/dir3            True                         2020-03-23 09:34:31Z rwxrw-rw-+   $superuser           $superuser

此命令从目录获取 ACL,更新/添加 ACL 条目,并设置回目录。 如果具有相同 AccessControlType/EntityId/DefaultScope 的 ACL 条目不存在,则将添加新的 ACL 条目,否则更新现有 ACL 条目的权限。

参数

-Acl

设置文件和目录的 POSIX 访问控制权限。 使用 New-AzDataLakeGen2ItemAclObject 创建此对象。

参数属性

类型:

PSPathAccessControlEntry[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

在运行 cmdlet 之前,提示你进行确认。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Context

Azure 存储上下文对象

参数属性

类型:IStorageContext
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

参数属性

类型:IAzureContextContainer
默认值:None
支持通配符:False
不显示:False
别名:AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-FileSystem

FileSystem 名称

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ReceiveManual
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Group

设置 blob 的拥有组。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

要更新的 Azure Datalake Gen2 项对象

参数属性

类型:AzureDataLakeGen2Item
默认值:None
支持通配符:False
不显示:False

参数集

ItemPipeline
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Metadata

指定目录或文件的元数据。

参数属性

类型:Hashtable
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Owner

设置 Blob 的所有者。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Path

应更新的指定文件系统中的路径。 可以是文件或目录,格式为“directory/file.txt”或“directory1/directory2/”。 不指定此参数将更新文件系统的根目录。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ReceiveManual
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Permission

设置文件所有者、文件拥有组和其他文件的 POSIX 访问权限。 可以向每个类授予读取、写入或执行权限。 支持符号(rwxrw-rw-)。 粘性位也受支持,并且它由字母 t 或 T 表示在最终字符位置,具体取决于其他类别的执行位是分别设置还是未设置,缺少 t 或 T 表示未设置粘滞位。与 ACL 结合使用无效。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Property

指定目录或文件的属性。 文件支持的属性包括:CacheControl、ContentDisposition、ContentEncoding、ContentLanguage、ContentMD5、ContentType。 目录支持的属性包括:CacheControl、ContentDisposition、ContentEncoding、ContentLanguage。

参数属性

类型:Hashtable
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输入

String

AzureDataLakeGen2Item

IStorageContext

输出

AzureDataLakeGen2Item