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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.