Skip to content

Instantly share code, notes, and snippets.

@shaneis
Created August 30, 2017 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneis/73df095f6bba1562e16f18394ae34b2e to your computer and use it in GitHub Desktop.
Save shaneis/73df095f6bba1562e16f18394ae34b2e to your computer and use it in GitHub Desktop.
Sums the sizes of ".bak", ".diff", and ".trn" files in a folder
Function Get-BackupFilesSizes {
$Bak = $Diff = $Trn = 0;
$Bak = (Get-ChildItem -File |
Where-Object { $_.Extension -eq '.bak' } |
Measure-Object -Property Length -Sum).Sum;
$Diff = (Get-ChildItem -File |
Where-Object { $_.Extension -eq '.diff' } |
Measure-Object -Property Length -Sum).Sum;
$Trn = (Get-ChildItem -File |
Where-Object { $_.Extension -eq '.trn' } |
Measure-Object -Property Length -Sum).Sum;
[PSCustomObject]@{
'Bak Files (GB)' = $Bak / 1GB
'Diff Files (GB)' = $Diff / 1GB
'Trn Files (GB)' = $Trn / 1GB
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment