I want to export multiple path file details into csv file. But it is only taking last path and storing details into csv file. FYI,
$Context = New-AzureStorageContext -StorageAccountName "cordus6abfsuat001" -UseConnectedAccount $path="path1", "path2", "path3", "path4", "path5" foreach($element in $path){ $temp = Get-AzDataLakeGen2ChildItem -Context $Context -FileSystem "root" -Path $element | export-csv "filename.csv" -NoTypeInformation }
I am expecting that all the above mentioned path file details will come to csv file. but it is taking last path details only.
After reproducing from my end, I could able to achieve your requirement after adding -Append to the existing export-csv
command. Below is the complete script that worked for me.
$path="dir1/", "dir2/", "dir3/", "dir4/", "dir5/"
foreach($element in $path)
{
Get-AzDataLakeGen2ChildItem -Context $context -FileSystem "root" -Path $element | export-csv "<filename>.csv" -Append -NoTypeInformation
}
RESULTS: