This is a PowerShell 1.0 version of a script that is discussed in the Hey Scriping Guy! blog: Can I Determine Which Folders Are Using the Most Space on My Computer? It uses two command line parameters: path and first that you can either modify directly or change from the command line. The path parameter specifies the search root, and the first parameter determines how many folders will be returned. For more information about this script, refer to the Hey Scripting Guy! blog from 8/19/2009 http://bit.ly/r725K 

PowerShell
Edit|Remove
# ---------------------------------------------------------
# ScriptingGamesBeginnerEvent8_PS1.ps1
# ed wilson, msft 8/21/2009
# PS1 version of HSG-08-19-09 http://bit.ly/1d8Rww
#
# ---------------------------------------------------------
Param(
 [string]$path = "c:\fso",
 [int]$first = 5
)# end param
# *** Function Here ***

function Get-DirSize ($path){

  BEGIN {}
 
  PROCESS{
    $size = 0
    $folders = @()
  
    foreach ($file in (Get-ChildItem $path -Force -ea SilentlyContinue)) {
      if ($file.PSIsContainer) {
        $subfolders = @(Get-DirSize $file.FullName)
        $size += $subfolders[-1].Size
        $folders += $subfolders
      } else {
        $size += $file.Length
      }
    }
  
    $object = New-Object -TypeName PSObject
    $object | Add-Member -MemberType NoteProperty -Name Folder `
                         -Value (Get-Item $path).FullName
    $object | Add-Member -MemberType NoteProperty -Name Size -Value $size
    $folders += $object
    Write-Output $folders
  }
  
  END {}
} # end function Get-DirSize

Function Get-FormattedNumber($size)
{
  IF($size -ge 1GB)
   {
      "{0:n2}" -f  ($size / 1GB) + " GigaBytes"
   }
 ELSEIF($size -ge 1MB)
    {
      "{0:n2}" -f  ($size / 1MB) + " MegaBytes"
    }
 ELSE
    {
      "{0:n2}" -f  ($size / 1KB) + " KiloBytes"
    }
} #end function Get-FormattedNumber

 # *** Entry Point to Script ***
 
 if(-not(Test-Path -Path $path)) 
   { 
     Write-Host -ForegroundColor red "Unable to locate $path" 
     Help $MyInvocation.InvocationName -full
     exit 
   }
 Get-DirSize -path $path | 
 Sort-Object -Property size -Descending | 
 Select-Object -Property folder, size -First $first |
 Format-Table -Property Folder, 
  @{ Label="Size of Folder" ; Expression = {Get-FormattedNumber($_.size)} }