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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

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....

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.