In Server 2008 R2, how can I develop a detailed report of how large every folder on the server's C: drive is?

In Server 2008 R2, how can I develop a detailed report of how large every folder on the server's C: drive is?

Is this something that I can do using a built in Server 2008 R2 feature or through a command line command (such as dir), or do I need to get a utility that can do this?

If so, exactly which utility would develop & display such a report for me?

Or, what sort of scripts are available that would be able to run such a report for me? If the report is saved as a .CSV file that will be fine since I will then be able to import this report into Excel.
IT GuyNetwork EngineerAsked:
Who is Participating?
There is a nifty tool called TreeSize which comes in a paid or free version. I have used the free version to scan hard drives and generate reports showing where the data is. Give it a shot and let me know if it is what you are looking for. I have used on servers and desktops!
IT GuyNetwork EngineerAuthor Commented:
Is this something that Windows Server 2008 R2 search could do?

I have tried typing in criteria such as c: folder:size:huge, but this doesn't seem to be a valid command.

I have already run a c:file:size:huge search query, and I have found only 4 files that meet this category, and they are all less than 400 MB in size.
I have not had any success with this on any OS from Windows. The TreeSize provides a graphical layout and you can then export results to .CSV or create PDF report.
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Darius GhassemCommented:
Windows 2008 Server R2 have that type of functionality yet from search.
You could try this script which uses the DirUse.exe command to build a report into Excel.

There is also TreeSize as mentioned, and SpaceMonger too.  SpaceMonger is graphical, it's very handy!


strLogFileName = "Results.txt"
strResultsFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & strLogFileName

strFolderToCheck = "C:\Temp"

Set objShell = CreateObject("WScript.Shell")
strCommand = "cmd /c diruse /s /m " & """" & strFolderToCheck & """" & " > """ & strResultsFile & """"
objShell.Run strCommand, 0, True

Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objResults = objFSO.OpenTextFile(strResultsFile, intForReading, False)
While Not objResults.AtEndOfStream
      strLine = objResults.ReadLine
      'If InStr(strLine, "Size (mb)") = 0 Then
            If strLine <> "" Then
                  strNewLine = Trim(Left(strLine, 13)) & "|"
                  strNewLine = strNewLine & Trim(Mid(strLine, 14, 7)) & "|"
                  strNewLine = strNewLine & Trim(Mid(strLine, 21))
                  If strResults = "" Then
                        strResults = strNewLine
                        strResults = strResults & VbCrLf & strNewLine
                  End If
            End If
      'End If
Set objResults = Nothing
objFSO.DeleteFile strResultsFile, True

MsgBox strResults

Set objExcelApp = CreateObject("Excel.Application")

Const xlAscending = 1
Const xlDescending = 2
Const xlCalculationManual = -4135
Const xlCalculationAutomatic = -4105
objExcelApp.Visible = True

objExcelApp.Calculation = xlCalculationManual
objExcelApp.ScreenUpdating = False

arrResultsRows = Split(strResults, VbCrLf)

ReDim arrResultsTable(UBound(arrResultsRows), UBound(Split(arrResultsRows(0), "|")))

For intRowNum = LBound(arrResultsRows) To UBound(arrResultsRows)
      For intColNum = LBound(Split(arrResultsRows(0), "|")) To UBound(Split(arrResultsRows(0), "|"))
            objExcelApp.ActiveSheet.Cells(intRowNum + 1, intColNum + 1).Value = Split(arrResultsRows(intRowNum), "|")(intColNum)
            'arrResultsTable(intRowNum, intColNum) = Split(arrResultsRows(intRowNum), "|")(intColNum)

objExcelApp.Selection.Sort objExcelApp.ActiveSheet.Range("A2"), xlDescending, , , , , , 1, 1, False, 1

'objExcelApp.Calculation = xlCalculationAutomatic
objExcelApp.ScreenUpdating = True

MsgBox "Done"

Open in new window

IT GuyNetwork EngineerAuthor Commented:

Does this script require that Microsoft Excel be installed on the server on which this script will be run?
Yes, because it uses Excel to sort the results.  I guess it could be changed to write unsorted data to CSV instead....or sorted by a disconnected recordset into CSV....

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.