You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求生成可遍历Blob Storage全层级文件详情的PowerShell脚本

一次性获取ADLS Gen2全层级文件/文件夹详情的PowerShell脚本

直接在Get-AzDataLakeGen2ChildItem命令中添加-Recurse参数,就能递归遍历指定路径下的所有层级内容,无需反复执行脚本。修改后的完整脚本如下:

$resourceGroupName = "RD-RDIPCloudMigration-AppResources-devtest"
$storageAccountName = "rdipstoragegen2"
$fileSystemName = "rdipdata"
$targetPath = "eval/raw/rdipclinicaltrial/data/warehouse/integrated/clntrl_reference_use.db"
$outputCsvPath = "test.csv"

# 获取存储账户密钥并创建上下文
$storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -AccountName $storageAccountName).Value[0]
$ctx = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey

# 递归获取所有层级的文件和文件夹,导出到CSV
Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $fileSystemName -Path $targetPath -Recurse | 
    Select-Object Name, FullName, Length, LastModified, IsDirectory | 
    Export-Csv -Path $outputCsvPath -NoTypeInformation

关键说明:

  • -Recurse:启用递归遍历,自动深入指定路径下的所有子文件夹,一次性获取所有层级的文件和文件夹信息
  • Select-Object:可选步骤,用于筛选需要导出的字段(如名称、完整路径、大小、修改时间、是否为文件夹),可根据需求调整字段列表
  • 若需获取整个文件系统(而非指定路径)的所有内容,移除-Path $targetPath参数即可

内容的提问来源于stack exchange,提问作者Swarnava Sen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 15:20:32