Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
leoce20
New Member

Report issues azure fileshare

Hi Dear 

I need download a report of usage fileshare storage account Azure but the report always show empti the csv i need know all files and size and export to excell, Can I helpme please.

I using a PS with the nex script:

Install-Module -Name ImportExcel -Force -AllowClobbe
##parametros de entrada
$resourceGroupName = "MyResourcegroup"
$storageAccName = "Mystorageaccname"
$fileShareName = "Myfsname"
$directoryPath = "Mypath"
##Customer tenant id
$customerTenantId = "###################98b"
##Subscription ID
Set-AzContext -SubscriptionId "###################################32a"
Import-Module ImportExcel
##Funcion para listar directorios
Function GetFiles {
Write-Host -ForegroundColor Green "Listing directories and files with sizes in MB.."
# Get the storage account context
$ctx = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName).Context
# Create an array to store file details
$fileDetails = @()
# List directories
$directories = Get-AZStorageFile -Context $ctx -ShareName $fileShareName
# Loop through directories
foreach ($directory in $directories) {
Write-Host -ForegroundColor Magenta "Directory Name: $($directory.Name)"
# Add directory details to the array
$fileDetails += [PSCustomObject]@{
DirectoryName = $directory.Name
FileName = $null # Placeholder for files
Size_MB = $null # Placeholder for file size in MB
}
# List files in the current directory
$files = Get-AZStorageFile -Context $ctx -ShareName $fileShareName -Path $directory.Name | Get-AZStorageFile
# Loop through files
foreach ($file in $files) {
# Convert size to MB
$sizeInMB = [math]::Round($file.Length / 1MB, 2)
# Add file details to the array
$fileDetails += [PSCustomObject]@{
DirectoryName = $directory.Name
FileName = $file.Name
Size_MB = $sizeInMB
}
}
}
# Get the current date in the specified format
$currentDateTime = Get-Date -Format "yyyyMMdd_HHmmss"
# Specify the new export path with file share name and current date with time as the suffix
$exportPath = "C:\temp\Downloads\lnt$fileShareName_$currentDateTime.xlsx"
# Export to Excel
$fileDetails | Export-Excel -Path $exportPath -AutoSize -Show
Write-Host "Excel exported to: $exportPath"
}

##Llamar la funcion
GetFiles

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @leoce20 ,

 

I recommend you checking if the script correctly accesses the fileshare data and if the Azure context is set properly. Additionally, please ensure that you have the necessary permissions to access the data. If you need more professional help, please post the question to the Azure Forum or contact Microsoft Support.Microsoft Azure Support Ticket | Microsoft Azure

 

Best regards,

Mengmeng Li

 

lbendlin
Super User
Super User

Maybe you want to post this in an Azure forum?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors