Bewerken

Delen via


Get-AzDataLakeGen2ChildItem

Lists sub directories and files from a directory or filesystem root.

Syntax

Get-AzDataLakeGen2ChildItem
   [-FileSystem] <String>
   [[-Path] <String>]
   [-FetchProperty]
   [-Recurse]
   [-MaxCount <Int32>]
   [-ContinuationToken <String>]
   [-AsJob]
   [-OutputUserPrincipalName]
   [-Context <IStorageContext>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Get-AzDataLakeGen2ChildItem cmdlet lists sub directorys and files in a directory or Filesystem in an Azure storage account. 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: List the direct sub items from a Filesystem

Get-AzDataLakeGen2ChildItem -FileSystem "filesystem1"

FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group               
----                 -----------  ------          ------------         -----------  -----                -----               
dir1                 True                         2020-03-13 13:07:34Z rwxr-x---    $superuser           $superuser          
dir2                 True                         2020-03-23 09:28:36Z rwxr-x---    $superuser           $superuser

This command lists the direct sub items from a Filesystem

Example 2: List recursively from a directory, and fetch Properties/ACL

Get-AzDataLakeGen2ChildItem -FileSystem "filesystem1" -Path "dir1/" -Recurse -FetchProperty

FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group               
----                 -----------  ------          ------------         -----------  -----                -----               
dir1/dir3            True                         2020-03-23 09:34:31Z rwx---rwx    $superuser           $superuser          
dir1/file1           False        1024            2020-03-23 09:29:18Z rwx---rwx    $superuser           $superuser           
dir1/testfile_1K_0   False        1024            2020-03-23 09:29:21Z rw-r-----    $superuser           $superuser

This command lists the direct sub items from a Filesystem

Example 3: List items recursively from a Filesystem in multiple batches

$MaxReturn = 1000
$FileSystemName = "filesystem1"
$Total = 0
$Token = $Null
do
 {
     $items = Get-AzDataLakeGen2ChildItem -FileSystem $FileSystemName -Recurse -MaxCount $MaxReturn  -ContinuationToken $Token
     $Total += $items.Count
     if($items.Length -le 0) { Break;}
     $Token = $items[$items.Count -1].ContinuationToken;
 }
 While ($null -ne $Token)
Echo "Total $Total items in Filesystem $FileSystemName"

This example uses the MaxCount and ContinuationToken parameters to list items recursively from a Filesystem in multiple batches. A small MaxCount can limit the items acount returned from single requst, may help on operation times out error, and limit the memory usage of Powershell. The first four commands assign values to variables to use in the example. The fifth command specifies a Do-While statement that uses the Get-AzDataLakeGen2ChildItem cmdlet to list items. The statement includes the continuation token stored in the $Token variable. $Token changes value as the loop runs. The final command uses the Echo command to display the total.

Parameters

-AsJob

Run cmdlet in the background

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

-Context

Azure Storage Context Object

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

-ContinuationToken

Continuation Token.

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

-DefaultProfile

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

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

-FetchProperty

Fetch the datalake item properties and ACL.

Type:SwitchParameter
Aliases:FetchPermission
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-FileSystem

FileSystem name

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

-MaxCount

The max count of the blobs that can return.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OutputUserPrincipalName

If speicify this parameter, the user identity values returned in the owner and group fields of each list entry will be transformed from Microsoft Entra Object IDs to User Principal Names. If not speicify this parameter, the values will be returned as Microsoft Entra Object IDs. Note that group and application Object IDs are not translated because they do not have unique friendly names.

Type:SwitchParameter
Aliases:UserPrincipalName
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

The path in the specified Filesystem that should be retrieved. Should be a directory, in the format 'directory1/directory2/'.

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

-Recurse

Indicates if will recursively get the Child Item. The default is false.

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

Inputs

String

IStorageContext

Outputs

AzureDataLakeGen2Item