Get-AzDataLakeGen2ChildItem
Lists sub directorys and files from a directory or filesystem root.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
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
PS C:\>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
PS C:\>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
PS C:\> $MaxReturn = 1000
PS C:\> $FileSystemName = "filesystem1"
PS C:\> $Total = 0
PS C:\> $Token = $Null
PS C:\> 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)
PS C:\> 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
Run cmdlet in the background
| Type: | SwitchParameter |
| 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 |
Continuation Token.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| 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 |
Fetch the datalake item properties and ACL.
| Type: | SwitchParameter |
| Aliases: | FetchPermission |
| 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 |
The max count of the blobs that can return.
| Type: | Nullable<T>[Int32] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
If speicify this parameter, the user identity values returned in the owner and group fields of each list entry will be transformed from Azure Active Directory Object IDs to User Principal Names. If not speicify this parameter, the values will be returned as Azure Active Directory 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 |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
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 |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Indicates if will recursively get the Child Item. The default is false.
| Type: | SwitchParameter |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |