How to find the largest PST files on our network.

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08
What is the best way to scan our network and find a list of all PST files and what pc's there on?  I am not a programmer or scripter so I may need some help. :)

Question by:goneal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 16

Expert Comment

ID: 26285046
Do you have romaing profiles at all?
LVL 16

Expert Comment

ID: 26285050

Author Comment

ID: 26285061
No roaming profiles.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 16

Accepted Solution

Raheem05 earned 1000 total points
ID: 26285161
OK there is a script which has been published before see below:


Hopefully this is what you are looking for
LVL 20

Expert Comment

by:Satya Pathak
ID: 26286636
Yes you can do it jost go through user profile and C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Outlook.

LVL 38

Assisted Solution

Shift-3 earned 1000 total points
ID: 26288204
Paste the script below into a text file with a .vbs extension.  Customize the contents of the arrContainers array on line 6 with the distinguished names of the OUs to search under.  Running the script will search each local drive on each computer and report the location of the largest .pst file on each one in a comma-delimited text file.

It should be noted that this is not terribly efficient and will necessarily take a very long time to run.  If you could narrow down the location to search on each drive, the script's performance could be considerably improved.

Const intMB = 1048576
On Error Resume Next
arrContainers = Array("ou=workstations,dc=yourdomain,dc=com")
strExt = "PST"
strReport = "report.csv"
strQuery = "SELECT DeviceID FROM Win32_LogicalDisk WHERE DriveType = 3"
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReport = objFSO.CreateTextFile(strReport, True)
objReport.WriteLine "Computer,Online,Largest " & strExt & " File,Size (MB)"
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
For Each strContainer in arrContainers
    Set objCommand.ActiveConnection = objConnection
    objCommand.CommandText = _
        "Select Name,distinguishedName From 'LDAP://" & strContainer & _
        "' Where objectCategory='computer'"  
    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
    Set objRecordSet = objCommand.Execute
    Do Until objRecordSet.EOF
        strComputer = objRecordSet.Fields("Name").Value
        strLargestFile = ""
        intLargestSize = 0
        If PingCheck(strComputer, 1, 500) Then
            Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
            Set colItems = objWMIService.ExecQuery(strQuery)
            For Each objItem In colItems
                strDrive = Left(objItem.DeviceID, 1)
                strCommand = "cmd /c @echo off & dir " & Chr(34) & "\\" & strComputer & _
                    "\" & strDrive & "$\*." & strExt & Chr(34) & " /a:-d /b /s"
                Set objWshScriptExec = objShell.Exec(strCommand)
                Set objStdOut = objWshScriptExec.StdOut
                Do Until objStdOut.AtEndOfStream
                    strFile = objStdOut.ReadLine
                    Set objFile = objFSO.GetFile(strFile)
                    intSize = objFile.Size
                    If intSize > intLargestSize Then
                        intLargestSize = intSize
                        strLargestFile = strFile
                    End If
            objReport.WriteLine strComputer & ",True," & Chr(34) & strLargestFile & Chr(34) & _
                "," & Round(intLargestSize/intMB, 1)
            objReport.WriteLine strComputer & ",False"
        End If
Function PingCheck(strTarget, strPings, intPause)
    Const ForReading = 1
    Set objShell = CreateObject("WScript.Shell")
    strTempDir = objShell.ExpandEnvironmentStrings("%temp%")
    strTempFile = strTempDir & "\script-" & strTarget & ".txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objShell.Run "%comspec% /c ping -n " & strPings & " -w 100 " & _
        strTarget & ">" & strTempFile, 0, True
    WScript.Sleep intPause
    objShell.Run "%comspec% /c ping -n " & strPings & " -w 100 " & _
        strTarget & ">>" & strTempFile, 0, True
    Set objTempFile = objFSO.OpenTextFile(strTempFile, ForReading)
    strOutput = objTempFile.ReadAll
    objFSO.DeleteFile strTempFile, True
    If InStr(strOutput, "bytes=32") > 0 Then
        PingCheck = True
        PingCheck = False
    End If
End Function

Open in new window


Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question