Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. function dtop {
  2. $DirectoryDesktop = "$USBDesktopPathServer", "$UserDesktopPath"
  3. foreach ($Directory in $DirectoryDesktop) {
  4. Get-ChildItem -Path $Directory -Recurse |
  5. Where-Object {-not $_.PSIsContainer} |
  6. Tee-Object -Variable Files |
  7. Group-Object -Property Extension |
  8. Select-Object -Property @{
  9. n = "Directory"
  10. e = {$Directory}
  11. },
  12. @{
  13. n = "Extension"
  14. e = { $_.Name -replace '^.' }
  15. },
  16. @{
  17. n = "Size (MB)"
  18. e={ [math]::Round( ( ( $_.Group | Measure-Object Length -Sum ).Sum / 1MB ), 2 ) }
  19. },
  20. Count
  21.  
  22. $Files |
  23. Measure-Object -Sum -Property Length |
  24. Select-Object -Property @{
  25. n = 'Extension'
  26. e = { 'Total' }
  27. },
  28. @{
  29. n = 'Size (MB)'
  30. e = { [math]::Round( ( $_.Sum / 1MB ), 2 ) }
  31. },
  32. Count
  33. }
  34. }
  35. $tst = dtop
  36. $tst
  37.  
  38. PS C:UsersMichael Nancarrow> dtop
  39.  
  40. Directory Extension Size (MB) Count
  41. --------- --------- --------- -----
  42. D:Deployment KitTestDesktop2 txt 0 1
  43. Total 0 1
  44. D:Deployment KitTestDesktop1 txt 0 11
  45. Total 0 11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement