Google
Search WWW Search msexchangetips.blogspot.com

Friday, September 15, 2006

Exchange: Search Network For PST Files

Summary:

In this article, I will provide a script to search your network for .PST files. Microsoft provides a script to search your local computer for a .PST file which you can find here.

http://www.microsoft.com/technet/scriptcenter/resources
/qanda/apr05/hey0408.mspx

I have modified it to also include the computer name since it will be intended to search multiple computers and to write the output to a csv file.

Copy the contents below and save to notepad. Rename this file to searchpst.vbs and save to C: drive.


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _

("Select * from CIM_DataFile Where Extension = 'pst'")

Set fso = CreateObject("Scripting.FileSystemObject")

set wfile = fso.opentextfile("c:\test.csv",2,true)

For Each objFile in colFiles

Wfile.writeline(strComputer & " " & objFile.Drive & " " & objFile.Path & " " & objFile.FileName & "." & objFile.Extension & " " & objFile.FileSize)

Next




Open your command prompt. Start, Run, CMD Ok. Ensure that you are at your your C:\>

Type the following

C:\>cscript searchpst.vbs

Once complete, go to your C: drive and locate text.csv. This csv file should include your computername, drive letter and path of your pst file, name of pst file and size.



Now if you wish to run this on multiple computers on the network you have couple options.

C:\>cscript searchpst.vbs computer1 computer2 computer3


Another option is to have this script read in the computer names from your computers OU in AD.

Copy the contents below to notepad. Save the file as searchpst1.vbs. Open your command prompt and type:

C:\>cscript searchpst1.vbs

Set colComputers = GetObject("LDAP://CN=Computers, DC=msexchange911, DC=net")
For Each objComputer in colComputers
strComputer = objComputer.CN
on error Resume next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile Where Extension = 'pst'")
Set fso = CreateObject("Scripting.FileSystemObject")
set wfile = fso.opentextfile("c:\test.csv",2,true)
For Each objFile in colFiles
Wfile.writeline(strComputer & " " & objFile.Drive & " " & objFile.Path & " " & objFile.FileName & "." & objFile.Extension & " " & objFile.FileSize)
next
next


References:

Running WMI Scripts on Multiple Computers
http://www.microsoft.com/technet/scriptcenter/resources
/tales/sg1102.mspx

How Do I Get a List of All PST Files on a Computer
http://www.microsoft.com/technet/scriptcenter/resources
/qanda/apr05/hey0408.mspx


James Chong
MCSE | M+, S+, MCTS, Security+
msexchangetips.blogspot.com

How useful was this article? Want to see a tip not listed? Please leave a comment.

29 Comments:

Anonymous Anonymous said...

Hi When I ran the first script I got the following error, can you help me out..?

C:\>cscript Searchpst.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Searchpst.vbs(6, 1) Microsoft VBScript compilation error: Expected statement

Thanks
Abhishek

4:44 AM  
Anonymous Anonymous said...

thanks, running script now on WS's. do you have one for finding psts in user shares?

5:39 AM  
Anonymous Anonymous said...

I received the same error as Abishek.

Thanks

5:52 AM  
Blogger Alexis said...

For work with exchange and other mails files-microsoft exchange pst password recovery,application is free as how as i remember,it works with the following mail accounts and services, such as IMAP mail servers, POP3 mail servers, Microsoft Exchange Server, web-based email and Microsoft Mail,except mail accounts, the program can unlock password protected files with *.pst extension,will sort all characters and find a password for you,recover passwords Outlook Exchange, when you cannot recover the password of an Exchange .pst or forgotten password Outlook Exchange Server.

11:26 AM  
Blogger Alex said...

I lost my password by ms outlook yesterday and friend advised-pst file password recovery.As he said tool has many other capacities and is free.It can recover lost or forgotten passwords for the mail accounts and *.pst files of the Microsoft Outlook mail client.

12:53 PM  
Blogger Alexis said...

With mails I worked for a long time,but programs for recover them I saw many.But one of them for me is the best-outlook 2003 pst recovery.Because it is free,program is reliable,besides that it can too view recovered messages in *.eml format even without Microsoft Outlook email client.

7:23 AM  
Anonymous Poll Script said...

Its highly informative. I would be visiting your blog hereafter regularly to gather valuable information.
Real Estate Script

10:57 PM  
Anonymous Anonymous said...

Script queries ALL available drive letters, which will slow the time to completion.
Is there a refinement of the GetObject() query that asks the cimv2 namespace for just local drives ?

otherwise, great scrip - thanks
Uncle_Nick

8:56 AM  
Anonymous web development company said...

Great post and very well written, that will really help you to learn Web Design, web development and SEO Strategies to help businesses web design company . You can find out many useful information about web design, seo and his work by visiting his blog and I Just wanna say thanks you for the information you have shared. Web Design Company India

5:20 AM  
Anonymous Anonymous said...

For many people, the first type of Men’ Footwear that we believe that during the consideration of Hogan scarpe for men in May of tennis shoes or even a generic cross-training shoes. For others, they believe in May of Hogan scarpe donna , it depends on your background. In fact, this category of hogan donna covers a wide range of sports shoes and leisure activities ranging from golf and basketball and soccer shoes race. I tend to buy Hogan scarpe uomo against training only because I am involved in a wide range of sports and weightlifting, the race to play basketball.

5:45 PM  
Blogger katty said...

Interesting blog, i usally be aware all about all different kind of sofware. i am online all the time, and this action allowed me to see a site costa rica homes for sale and i like it too much, beyond all doubt without my computer and a great network i never would have seen this site too.

7:42 AM  
Blogger JD said...

thanks! works great!

2:51 PM  
Blogger JD said...

This comment has been removed by the author.

2:51 PM  
Anonymous Anonymous said...

PLEASE help
hi I have the same error as form the comment below:



C:\>cscript Searchpst.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Searchpst.vbs(6, 1) Microsoft VBScript compilation error: Expected statement

1:16 PM  
Anonymous buy vps said...

This is really amazing. You helped me to open up my eyes. Thanks for publishing and I'm looking forward to your new posts.
John F. from VpsWebServer.
Visit us and learn all about vps hosting.

5:08 AM  
Anonymous vps hosting said...

Wonderful blog post,I will save it to favorites and let all my friends know about it. It's been a pleasure to read something like this.

Learn all about Microsoft Exchange.

5:10 AM  
Anonymous Anonymous said...

This was SO helpful! Thank you so much!!!!

11:21 AM  
Anonymous Brad Fallon said...

Do pst files contain all the profile information needed to set up Outlook 03 on a new computer?

6:37 AM  
Anonymous fico score said...

Two PST files in my laptop, one ask for password other cant be access denied how do i solve this problem?

4:23 AM  
Blogger tweety said...

Nice stuff for sharing. Thanks to you! G&G is a software developer for mobile

11:26 AM  
Anonymous 1st birthday themes said...

How to import .pst files from another email account in such a way dat those emails do not mix with d existing?

7:52 AM  
Anonymous 1 year old birthday party said...

Two PST files in my laptop, one ask for password other cant be access denied how do i solve this problem?

12:46 PM  
Anonymous sexshoptienda.wordpress.com said...

Quite effective material, thank you for the article.

10:09 AM  
Anonymous shmoogle said...

How to import .pst files from another email account in such a way dat those emails do not mix with d existing?

9:30 AM  
Anonymous eb-5 visa said...

How to import .pst files from another email account in such a way dat those emails do not mix with d existing?

7:43 AM  
Anonymous icon brickell said...

Why do i get an application error whenever i open a new window?

8:41 AM  
Anonymous Anonymous said...

if you don't respond to errors which people are encountering then this is pretty useless!

C:\>cscript Searchpst.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Searchpst.vbs(6, 1) Microsoft VBScript compilation error: Expected statement

2:44 AM  
Anonymous Anonymous said...

C:\Searchpst.vbs(6, 1) Microsoft VBScript compilation error: Expected statement

Probably a formatting error?

5:39 AM  
Anonymous Anonymous said...

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery("select * from CIM_DataFile Where Extension = 'pst'")

Set fso = CreateObject("Scripting.FileSystemObject")

Set wfile = fso.opentextfile("c:\pst\test.csv",2,true)

For Each objFile in colFiles

Wfile.writeline(strComputer & " " & objFile.Drive & " " & objFile.Path & " " & objFile.FileName & "." & objFile.Extension & " " & objFile.FileSize)

Next

Working script

5:22 AM  

Post a Comment

<< Home

xml:lang="en" lang="en"> MS Exchange Tips: Exchange: Search Network For PST Files