For 2 AM calls, I use scanner.exe as it's just an executable. http://www.steffengerlach.de/freeware/ As to using a utility vs adding to your scripting library, it depends on your goal. Adding to your scripting library is useful in technique and flexibility. There is nothing wrong with windirstat, just sometimes, a quick script fulfills your needs and has the advantage of just being there already.
In the end, either set of tools works. Steven Peck http://www.blkmtn.org On Thu, Nov 10, 2011 at 2:54 PM, Cynicalgeek <[email protected]> wrote: > Just use WinDirStat and be done with it, unless you're trying to script > this. > > > On Thu, Nov 10, 2011 at 5:09 PM, Steven Peck <[email protected]> wrote: > >> Well, mine was the seriously lazy use what's there method. It's not like >> I created anything, just discovered and leveraged what was there :) >> >> >> >> On Thu, Nov 10, 2011 at 1:03 PM, Michael B. Smith >> <[email protected]>wrote: >> >>> Steven’s solution is arguably better than mine. J**** >>> >>> ** ** >>> >>> -----get-foldersize.ps1-----**** >>> >>> Param(**** >>> >>> [string]$path = $home,**** >>> >>> [switch]$sortBySize**** >>> >>> )**** >>> >>> ** ** >>> >>> function Get-FolderSize( $path )**** >>> >>> {**** >>> >>> $code = { ('{0:0.0} MB' -f ($this/1MB)) }**** >>> >>> Get-ChildItem -Path $Path |**** >>> >>> Where-Object { $_.Length -eq $null } |**** >>> >>> ForEach-Object {**** >>> >>> Write-Progress -Activity 'Calculating Total Size >>> for:' -Status $_.FullName**** >>> >>> $sum = Get-ChildItem $_.FullName -Recurse >>> -ErrorAction SilentlyContinue |**** >>> >>> Measure-Object -Property Length -Sum >>> -ErrorAction SilentlyContinue**** >>> >>> $bytes = $sum.Sum**** >>> >>> if ($bytes -eq $null) { $bytes = 0 }**** >>> >>> $result = 1 | Select-Object -Property Path, >>> TotalSize**** >>> >>> $result.Path = $_.FullName**** >>> >>> $result.TotalSize = $bytes | **** >>> >>> Add-Member -MemberType ScriptMethod -Name >>> toString -Value $code -Force -PassThru **** >>> >>> $result**** >>> >>> }**** >>> >>> }**** >>> >>> ** ** >>> >>> if( $sortBySize )**** >>> >>> {**** >>> >>> Get-FolderSize $path | sort -Property TotalSize**** >>> >>> }**** >>> >>> else**** >>> >>> {**** >>> >>> Get-FolderSize $path**** >>> >>> }**** >>> >>> -----get-foldersize.ps1-----**** >>> >>> ** ** >>> >>> Regards,**** >>> >>> ** ** >>> >>> Michael B. Smith**** >>> >>> Consultant and Exchange MVP**** >>> >>> http://TheEssentialExchange.com**** >>> >>> ** ** >>> >>> *From:* John Hornbuckle [mailto:[email protected]] >>> *Sent:* Thursday, November 10, 2011 3:35 PM >>> >>> *To:* NT System Admin Issues >>> *Subject:* RE: Easy Way to View and Sort By Folder Sizes**** >>> >>> ** ** >>> >>> Can you tell a PS novice how to get this to sort by size? That would >>> make it perfect.**** >>> >>> ** ** >>> >>> ** ** >>> >>> John**** >>> >>> ** ** >>> >>> *From:* Michael B. Smith [mailto:[email protected]] >>> *Sent:* Thursday, November 10, 2011 1:41 PM >>> *To:* NT System Admin Issues >>> *Subject:* RE: Easy Way to View and Sort By Folder Sizes**** >>> >>> ** ** >>> >>> I wrote this for someone here (well, on some mailing list, I think it >>> was this one) a couple months ago, but I use it all the time now.**** >>> >>> ** ** >>> >>> -----get-foldersize.ps1-----**** >>> >>> function Get-FolderSize( $path = $home )**** >>> >>> {**** >>> >>> $code = { ('{0:0.0} MB' -f ($this/1MB)) }**** >>> >>> Get-ChildItem -Path $Path |**** >>> >>> Where-Object { $_.Length -eq $null } |**** >>> >>> ForEach-Object {**** >>> >>> Write-Progress -Activity 'Calculating Total Size for:' >>> -Status $_.FullName**** >>> >>> $sum = Get-ChildItem $_.FullName -Recurse -ErrorAction >>> SilentlyContinue |**** >>> >>> Measure-Object -Property Length -Sum -ErrorAction >>> SilentlyContinue**** >>> >>> $bytes = $sum.Sum**** >>> >>> if ($bytes -eq $null) { $bytes = 0 }**** >>> >>> $result = 1 | Select-Object -Property Path, TotalSize**** >>> >>> $result.Path = $_.FullName**** >>> >>> $result.TotalSize = $bytes | **** >>> >>> Add-Member -MemberType ScriptMethod -Name toString -Value $code >>> -Force -PassThru **** >>> >>> $result**** >>> >>> }**** >>> >>> }**** >>> >>> ** ** >>> >>> Get-FolderSize $args**** >>> >>> -----get-foldersize.ps1-----**** >>> >>> ** ** >>> >>> Example:**** >>> >>> ** ** >>> >>> PS C:\Scripts> .\Get-FolderSize.ps1 c:\windows**** >>> >>> ** ** >>> >>> Path >>> TotalSize**** >>> >>> ---- >>> ---------**** >>> >>> C:\windows\ADAM >>> 3.6 MB**** >>> >>> C:\windows\ADWS >>> 0.7 MB**** >>> >>> C:\windows\AppCompat >>> 0.1 MB**** >>> >>> C:\windows\AppPatch >>> 10.4 MB**** >>> >>> C:\windows\assembly >>> 2436.4 MB**** >>> >>> C:\windows\Boot >>> 19.7 MB**** >>> >>> C:\windows\Branding >>> 2.2 MB**** >>> >>> C:\windows\CSC >>> 0.0 MB**** >>> >>> C:\windows\Cursors >>> 0.1 MB**** >>> >>> C:\windows\debug >>> 8.6 MB**** >>> >>> C:\windows\diagnostics >>> 1.0 MB**** >>> >>> C:\windows\DigitalLocker >>> 0.0 MB**** >>> >>> C:\windows\Downloaded Installations >>> 4.9 MB**** >>> >>> C:\windows\Downloaded Program Files >>> 19.7 MB**** >>> >>> C:\windows\Driver Cache >>> 0.3 MB**** >>> >>> C:\windows\en >>> 0.1 MB**** >>> >>> C:\windows\en-US >>> 0.1 MB**** >>> >>> C:\windows\Fonts >>> 376.1 MB**** >>> >>> C:\windows\Globalization >>> 9.6 MB**** >>> >>> C:\windows\Help >>> 68.1 MB**** >>> >>> C:\windows\idmu >>> 0.3 MB**** >>> >>> C:\windows\IME >>> 136.8 MB**** >>> >>> ……**** >>> >>> ** ** >>> >>> Regards,**** >>> >>> ** ** >>> >>> Michael B. Smith**** >>> >>> Consultant and Exchange MVP**** >>> >>> http://TheEssentialExchange.com**** >>> >>> ** ** >>> >>> *From:* John Hornbuckle [mailto:[email protected]] >>> *Sent:* Thursday, November 10, 2011 10:42 AM >>> *To:* NT System Admin Issues >>> *Subject:* Easy Way to View and Sort By Folder Sizes**** >>> >>> ** ** >>> >>> We use folder redirection here, and I’m trying to get a handle on which >>> users have the most stuff.**** >>> >>> ** ** >>> >>> So we have something like:**** >>> >>> ** ** >>> >>> x:\path\user1**** >>> >>> x:\path\user2**** >>> >>> x:\path\user3**** >>> >>> ** ** >>> >>> and so on.**** >>> >>> ** ** >>> >>> I’d like to look at x:\path and sort all the folders in it by size, >>> displaying the size in MB. So the results would be something like:**** >>> >>> ** ** >>> >>> x:\path\user3 500 MB**** >>> >>> x:\path\user1 200 MB**** >>> >>> x:\path\user2 100 MB**** >>> >>> ** ** >>> >>> What’s the easiest way to do this?**** >>> >>> ** ** >>> >>> I’ll need specifics (e.g., don’t tell me I can do it with PS unless >>> you’re gonna tell me precisely how).**** >>> >>> ** ** >>> >>> :)**** >>> >>> ** ** >>> >>> ** ** >>> >>> ** ** >>> >>> John Hornbuckle, MSMIS, PMP**** >>> >>> MIS Department**** >>> >>> Taylor County School District**** >>> >>> www.taylor.k12.fl.us**** >>> >>> ** ** >>> >>> ** ** >>> >>> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >>> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >>> >>> --- >>> To manage subscriptions click here: >>> http://lyris.sunbelt-software.com/read/my_forums/ >>> or send an email to [email protected] >>> with the body: unsubscribe ntsysadmin**** >>> >>> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >>> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >>> >>> --- >>> To manage subscriptions click here: >>> http://lyris.sunbelt-software.com/read/my_forums/ >>> or send an email to [email protected] >>> with the body: unsubscribe ntsysadmin**** >>> >>> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >>> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >>> >>> --- >>> To manage subscriptions click here: >>> http://lyris.sunbelt-software.com/read/my_forums/ >>> or send an email to [email protected] >>> with the body: unsubscribe ntsysadmin**** >>> >>> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >>> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >>> >>> --- >>> To manage subscriptions click here: >>> http://lyris.sunbelt-software.com/read/my_forums/ >>> or send an email to [email protected] >>> with the body: unsubscribe ntsysadmin >>> >> >> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >> >> --- >> To manage subscriptions click here: >> http://lyris.sunbelt-software.com/read/my_forums/ >> or send an email to [email protected] >> with the body: unsubscribe ntsysadmin >> > > > > -- > -cynicalgeek- > cynicalgeek<at>gmail.com > -- > > ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ > ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ > > --- > To manage subscriptions click here: > http://lyris.sunbelt-software.com/read/my_forums/ > or send an email to [email protected] > with the body: unsubscribe ntsysadmin > ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
