Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dtop {
- $DirectoryDesktop = "$USBDesktopPathServer", "$UserDesktopPath"
- foreach ($Directory in $DirectoryDesktop) {
- Get-ChildItem -Path $Directory -Recurse |
- Where-Object {-not $_.PSIsContainer} |
- Tee-Object -Variable Files |
- Group-Object -Property Extension |
- Select-Object -Property @{
- n = "Directory"
- e = {$Directory}
- },
- @{
- n = "Extension"
- e = { $_.Name -replace '^.' }
- },
- @{
- n = "Size (MB)"
- e={ [math]::Round( ( ( $_.Group | Measure-Object Length -Sum ).Sum / 1MB ), 2 ) }
- },
- Count
- $Files |
- Measure-Object -Sum -Property Length |
- Select-Object -Property @{
- n = 'Extension'
- e = { 'Total' }
- },
- @{
- n = 'Size (MB)'
- e = { [math]::Round( ( $_.Sum / 1MB ), 2 ) }
- },
- Count
- }
- }
- $tst = dtop
- $tst
- PS C:UsersMichael Nancarrow> dtop
- Directory Extension Size (MB) Count
- --------- --------- --------- -----
- D:Deployment KitTestDesktop2 txt 0 1
- Total 0 1
- D:Deployment KitTestDesktop1 txt 0 11
- Total 0 11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement