-
Notifications
You must be signed in to change notification settings - Fork 0
/
CalculateDFSRStagingQuotas.ps1
33 lines (25 loc) · 1.13 KB
/
CalculateDFSRStagingQuotas.ps1
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
# Script to calculate the staging quota requirements for all DFS replicated shares
#
# Where to save the results to?
$outputFile = 'C:\BrockIT\Scripts\output\DFSRStagingSizes.csv'
# Get all replicated folders from DFS
$replicatedFolders = Get-DfsReplicatedFolder
# Create a blank table to hold the objects
$dfsnDetails = @()
# Iterate through the shares
foreach ($replicatedFolder in $replicatedFolders) {
# Get the top 32 biggest files from the share
$biggestFiles = Get-ChildItem -Path $replicatedFolder.DfsnPath -Recurse | Sort-Object -Property Length -Descending | Select-Object -First 32
# Sum the sizes of the top 32 files
$filesSum = $biggestFiles | Measure-Object -Property Length –Sum
# Convert the value to MB and round up
$stagingQuotaMB = [math]::Ceiling($filesSum.Sum / 1MB)
# Add an object with the details in to the results table
$dfsnDetails += [pscustomobject]@{
'FolderName' = $replicatedFolder.FolderName;
'DfsnPath' = $replicatedFolder.DfsnPath;
'StagingQuotaMB' = $stagingQuotaMB;
}
}
# Output the details to a CSV file
$dfsnDetails | Export-Csv -Path $outputFile