The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
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
Maybe you want to post this in an Azure forum?