Пожалуйста, используйте код ниже (напишите в PowerShell ISE):
$fileinfor =@{count=0;length=0}
function file_info()
{
$context = New-AzStorageContext -StorageAccountName your_storage_account_name -StorageAccountKey your_storage_account_key
$shares = Get-AzStorageShare -Context $context
foreach($share in $shares)
{
#get all the files and directories in a file share
$filesAndDirs = Get-AzStorageFile -ShareName $share.name -Context $context
foreach($f in $filesAndDirs)
{
if($f.gettype().name -eq "CloudFile")
{
Write-Output $f.name
$fileinfor["count"]++
$fileinfor["length"]=$fileinfor["length"]+$f.Properties.Length
}
elseif($f.gettype().name -eq "CloudFileDirectory")
{
list_subdir($f)
}
}
}
Write-Output ""
Write-Output "File total count: "$fileinfor["count"]
Write-Output "File total length: "$fileinfor["length"]
}
function list_subdir([Microsoft.WindowsAzure.Storage.File.CloudFileDirectory]$dirs)
{
$path = $dirs.Uri.PathAndQuery.Remove(0,($dirs.Uri.PathAndQuery.IndexOf('/',1)+1))
$filesAndDirs = Get-AzStorageFile -ShareName $dirs.share.name -Path $path -Context $context | Get-AzStorageFile
foreach($f in $filesAndDirs)
{
if($f.gettype().name -eq "CloudFile")
{
Write-Output $f.name
$fileinfor["count"]++
$fileinfor["length"]=$fileinfor["length"]+$f.Properties.Length
}
elseif($f.gettype().name -eq "CloudFileDirectory")
{
list_subdir($f)
}
}
}
file_info
И результат теста: