-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetContainerUsageMultiThread.ps1
More file actions
58 lines (56 loc) · 1.77 KB
/
GetContainerUsageMultiThread.ps1
File metadata and controls
58 lines (56 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
[CmdletBinding()]
param (
# Storage Account Name
[Parameter(Mandatory)]
[string]
$StorageAccountName,
[Parameter(Mandatory)]
[string]
$storage_shared_key,
# Filesystem/Container name
[Parameter(Mandatory)]
[string]
$FileSystem,
# Root filesystem path
[Parameter(Mandatory)]
[string]
$RootPath
)
begin {
$FolderSizes = [System.Collections.ArrayList]::Synchronized( `
(New-Object System.Collections.ArrayList))
}
process {
$ctx = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $storage_shared_key
$dirlist = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $FileSystem -Path $RootPath | Select-Object Path
$dirlist
$MaxReturn = 3000
$dirlist | Foreach-Object -Parallel {
$MaxReturn = $using:MaxReturn
$FolderSizes = $using:FolderSizes
$FileSystem = $using:FileSystem
$ctx = $using:ctx
$Total = 0
$Count = 0
$Token = $null
$output = "c:\output\"
do {
$filelist = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $FileSystem -Recurse -MaxCount $MaxReturn -Path $_.Path -ContinuationToken $Token | Where-Object IsDirectory -eq $false
$Stats = $filelist | Measure-Object -Property Length -Sum
$Total += $Stats.Sum
$Count += $Stats.Count
$Token = $filelist[$filelist.Count -1].ContinuationToken
} While ($Token -ne $null)
$Result = [PSCustomObject]@{
Path = $_.Path
Size = $Total
Count = $Count
Date = (Get-Date)
}
#$FolderSizes.Add(@($Result)) | Out-Null
Write-Host $Result
$folder_name2 = $_.Path.Replace("/", "_")
$outputPath = $output + "\BlobFiles_" + $folder_name2 + ".csv"
$Result | Export-Csv -Path $outputPath
}
}