Update-AzDataLakeGen2Item
Update a file or directory on properties, metadata, permission, ACL, and owner.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
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>]
Update-AzDataLakeGen2Item
-InputObject <AzureDataLakeGen2Item>
[-Permission <String>]
[-Owner <String>]
[-Group <String>]
[-Property <Hashtable>]
[-Metadata <Hashtable>]
[-Acl <PSPathAccessControlEntry[]>]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Update-AzDataLakeGen2Item cmdlet updates a file or directory on properties, metadata, permission, ACL, and owner. This cmdlet only works if Hierarchical Namespace is enabled for the Storage account. This kind of account can be created by run "New-AzStorageAccount" cmdlet with "-EnableHierarchicalNamespace $true".
Examples
Example 1: Create an ACL object with 3 ACL entry, and update ACL to all items in a Filesystem recursively
PS C:\>$acl = New-AzDataLakeGen2ItemAclObject -AccessControlType user -Permission rwx
PS C:\>$acl = New-AzDataLakeGen2ItemAclObject -AccessControlType group -Permission rw- -InputObject $acl
PS C:\>$acl = New-AzDataLakeGen2ItemAclObject -AccessControlType other -Permission "rw-" -InputObject $acl
PS C:\>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-rw- $superuser $superuser
dir1/file1 False 1024 2020-03-23 09:29:18Z rwxrw-rw- $superuser $superuser
dir2 True 2020-03-23 09:28:36Z rwxrw-rw- $superuser $superuser
This command first creates an ACL object with 3 acl entry (use -InputObject parameter to add acl entry to existing acl object), then get all items in a filesystem and update acl on the items.
Example 2: Update all properties on a file, and show them
PS C:\> $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'
PS C:\> $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
PS C:\> $file.ACL
DefaultScope AccessControlType EntityId Permissions
------------ ----------------- -------- -----------
False User rwx
False Group rw-
False Other rw-
PS C:\> $file.Permissions
Owner : Execute, Write, Read
Group : Write, Read
Other : Write, Read
StickyBit : False
ExtendedAcls : False
PS C:\> $file.Properties.Metadata
Key Value
--- -----
tag2 value2
tag1 value1
PS C:\> $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
This command updates all properties on a file (ACL, permission,owner, group, metadata, property can be updated with any conbination), and show them in Powershell console.
Example 3: Add an ACL entry to a directory
## Get the origin ACL
PS C:\> $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)
PS C:\> $acl = Set-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityId $id -Permission rw- -InputObject $acl
# set the new acl to the directory
PS C:\> 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
This command gets ACL from a directory, updates/adds an ACL entry, and sets back to the directory. If ACL entry with same AccessControlType/EntityId/DefaultScope not exist, will add a new ACL entry, else update permission of existing ACL entry.
Parameters
Sets POSIX access control rights on files and directories. Create this object with New-AzDataLakeGen2ItemAclObject.
| Type: | PSPathAccessControlEntry[] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
| Type: | SwitchParameter |
| Aliases: | cf |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Azure Storage Context Object
| Type: | IStorageContext |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with Azure.
| Type: | IAzureContextContainer |
| Aliases: | AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
FileSystem name
| Type: | String |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Sets the owning group of the blob.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Azure Datalake Gen2 Item Object to update
| Type: | AzureDataLakeGen2Item |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies metadata for the directory or file.
| Type: | Hashtable |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Sets the owner of the blob.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The path in the specified Filesystem that should be updated. Can be a file or directory In the format 'directory/file.txt' or 'directory1/directory2/'. Not specify this parameter will update the root directory of the Filesystem.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Sets POSIX access permissions for the file owner, the file owning group, and others. Each class may be granted read, write, or execute permission. Symbolic (rwxrw-rw-) is supported. Invalid in conjunction with Acl.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Specifies properties for the directory or file. The supported properties for file are: CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ContentMD5, ContentType. The supported properties for directory are: CacheControl, ContentDisposition, ContentEncoding, ContentLanguage.
| Type: | Hashtable |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
| Type: | SwitchParameter |
| Aliases: | wi |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |