This will display the size (in MegaBytes) of your archive and number of files. If you use the ‘-Export’ switch, it will export a list of files to each directory. You can use Robocopy as an alternative to Get-ChildItem for better performance.
function Get-ArchiveSize {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline)]
[string[]]$Path,
[switch]$Export
)
Process {
foreach ($string in $path){
Write-Verbose "Searching [$string]"
$files = Get-ChildItem -Path $string -File -Attributes Archive -Recurse
$measure = $files | Measure-Object -Sum Length |
Select-Object @{n='Sum';exp={"{0:N2} (MB)" -f ($_.Sum / 1MB)}},
Count | Format-Table -AutoSize
$measure
If ($Export){$files.FullName | Out-File "$string\filelist.txt" -Append}
}
}
}
# Examples:
# Get-ArchiveSize -Path "\\path\one","\\path\two" -Verbose
# "\\path\one","\\path\two" | Get-ArchiveSize -Verbose -Export