你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Get-AzDataLakeGen2ChildItem
列出目录或文件系统根目录中的子目录和文件。
语法
Get-AzDataLakeGen2ChildItem
[-FileSystem] <String>
[[-Path] <String>]
[-FetchProperty]
[-Recurse]
[-MaxCount <Int32>]
[-ContinuationToken <String>]
[-AsJob]
[-OutputUserPrincipalName]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
Get-AzDataLakeGen2ChildItem cmdlet 列出了 Azure 存储帐户中目录或文件系统中的子目录和文件。 仅当为存储帐户启用了分层命名空间时,此 cmdlet 才有效。 可以使用“-EnableHierarchicalNamespace $true”运行“New-AzStorageAccount”cmdlet 来创建此类帐户。
示例
示例 1:列出文件系统中的直接子项
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
此命令列出文件系统中的直接子项
示例 2:从目录以递归方式列出,并提取 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
此命令列出文件系统中的直接子项
示例 3:以递归方式从文件系统以多个批方式列出项
$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"
此示例使用 MaxCount 和 ContinuationToken 参数以递归方式从文件系统以多个批次列出项。 一个小 MaxCount 可以限制从单个 requst 返回的项,可能有助于作超时错误,并限制 Powershell 的内存使用量。 前四个命令将值分配给在示例中要使用的变量。 第五个命令指定 Do-While 语句,该语句使用 Get-AzDataLakeGen2ChildItem cmdlet 列出项。 该语句包括存储在$Token变量中的延续标记。 $Token循环运行时更改值。 最后一个命令使用 Echo 命令显示总计。
参数
-AsJob
在后台运行 cmdlet
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Context
Azure 存储上下文对象
类型: | IStorageContext |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-ContinuationToken
继续标记。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-FetchProperty
提取 datalake 项属性和 ACL。
类型: | SwitchParameter |
别名: | FetchPermission |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-FileSystem
FileSystem 名称
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-MaxCount
可返回的 Blob 的最大计数。
类型: | Nullable<T>[Int32] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-OutputUserPrincipalName
如果指定此参数,则每个列表项的所有者和组字段中返回的用户标识值将从 Microsoft Entra 对象 ID 转换为用户主体名称。 如果未指定此参数,这些值将作为Microsoft Entra 对象 ID 返回。 请注意,组和应用程序对象 ID 不会翻译,因为它们没有唯一的友好名称。
类型: | SwitchParameter |
别名: | UserPrincipalName |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Path
应检索的指定文件系统中的路径。 应该是一个目录,格式为“directory1/directory2/”。
类型: | String |
Position: | 1 |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Recurse
指示是否以递归方式获取子项。 默认值为 false。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |