5 ms·
Man i do think this is a big step for windows , it's 2016 and still complex to pull a du -sh or df on windows. Things we take for granted on *nixes. Much love.
by bechampion 11y ago
Man i do think this is a big step for windows , it's 2016 and still complex to pull a du -sh or df on windows.
Things we take for granted on *nixes.
Much love.
- rat87 11y agoAccording to http://stackoverflow.com/a/868290/259130 http://stackoverflow.com/a/868290/259130 function directory-summary($dir=".") { get-childitem $dir | % { $f = $_ ; get-childitem -r $_.FullName | measure-object -property length -sum | select @{Name="Name";Expression={$f}},Sum} } I could get a shorter non exact version if I was on windows.
- bechampion 11y agothat's almost as easy as just typing "du -sh"
- MandieD 11y agoAdd that function (or whatever combo of attributes you want to see on a regular basis) to your PowerShell profile, as well as this line: New-Alias -Name "du" -Value "Directory-Summary"
- nailer 11y agoFor 'du': > Get-ChildItem C:\windows | Measure-Object -property length -sum Count : 28 Average : Sum : 6407920 Maximum : Minimum : Property : length For 'df': > get-WmiObject win32_logicaldisk DeviceID : C: DriveType : 3 ProviderName : FreeSpace : 21796540416 Size : 31685865472 VolumeName : DeviceID : D: DriveType : 5 ProviderName : FreeSpace : Size : VolumeName : DeviceID : Z: DriveType : 4 ProviderName : \\veertu\share FreeSpace : 44674220032 Size : 399999991808 VolumeName : VeertuFS
- useerup 11y agoAnd you just built du with a single line of PowerShell. Also, you demonstrated the full syntax. The short form would be (leveraging aliases, positional parameters and unambiguous short parameter names): For du: ls C:\Windows\ | measure length -sum For df: gwmi win32_logicaldisk
- noinsight 11y agoOr you can just download du.exe from SysInternals to get a du-like tool.
- deleted 11y ago[deleted]
- jle17 11y agoMicrosoft provides a du implementation in sysinternals stuff, but you have to install it and I think even accept a licence in a graphical window the first time you launch it... They have neglected the CLI for years and powershell while I guess it has its uses for scripting is light years behind *nix stuff as an interactive shell.
- zyx321 11y ago>but you have to install it and I think even accept a licence in a graphical window You can -accepteula from the command line and the "installation" is downloading and extracting a zip file. If there's an internet connection, you could even run it straight off of Micrsoft's servers via SMB.