Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
Hi NJ,
you are very close! The main issue is with this line in your recursive function:
$files = Get-AzStorageFile -Context $storageContext -ShareName $fileshareName -Path $directoryPath | Get-AzStorageFile
Remove the Pipe from the recursive function. The second Get-AzStorageFile is unnecessary and causes the function to fail in retrieving subfolders and files.
Apart from that few basic changes you can try
1.Start from the root path ("") to ensure all folders and files are included.
$directories = Get-AzStorageFile -ShareName $fileshareName -Context $storageContext | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"}
doesn’t specify a -Path, so it defaults to the root and only lists the root-level directories. It doesn’t trigger recursion into subdirectories unless explicitly handled.
- Function call placement
The recursive function is defined after it’s called in the loop:
foreach ($item in $directories) {
...
Get-AzFileShareContent -shareName $fileShareName -directoryPath $directoryPath
}
define the function before calling to avoid scope issues