Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Get-AzDataLakeGen2ChildItem

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

Syntax

Default (Default)

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 directories 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 number of items returned from a single request, may help prevent operation timeout errors, and reduce 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

Parameter properties

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

Parameter sets

-Context

Azure Storage Context Object

Parameter properties

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

Parameter sets

-ContinuationToken

Continuation Token.

Parameter properties

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

Parameter sets

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRmContext, AzureCredential

Parameter sets

-FetchProperty

Fetch the datalake item properties and ACL.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:FetchPermission

Parameter sets

-FileSystem

FileSystem name

Parameter properties

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

Parameter sets

-MaxCount

The max count of the blobs that can return.

Parameter properties

Type:

Nullable<T>[Int32]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-OutputUserPrincipalName

If specify 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 specify 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.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:UserPrincipalName

Parameter sets

-Path

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

Parameter properties

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

Parameter sets

-Recurse

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

Parameter properties

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

Parameter sets

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.

Inputs

String

IStorageContext

Outputs

AzureDataLakeGen2Item


Feedback

Was this page helpful?