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.

39 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 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 DEMPC said...

thanks! works great!

2:51 PM  
Blogger DEMPC 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  
Anonymous Anonymous said...

Pstviewer.com has software for viewing and searching .pst files without Outlook.

2:34 PM  
Blogger oakleyses said...

louis vuitton outlet, oakley sunglasses, michael kors handbags, cheap jordans, prada handbags, uggs outlet, michael kors outlet, oakley sunglasses, uggs on sale, ray ban sunglasses, burberry outlet, tiffany jewelry, uggs on sale, kate spade, gucci handbags, ray ban sunglasses, prada outlet, longchamp outlet, louboutin uk, burberry factory outlet, tory burch outlet, nike air max, tiffany jewelry, christian louboutin, louboutin shoes, oakley sunglasses, cheap oakley sunglasses, chanel handbags, michael kors outlet store, louis vuitton outlet, nike outlet, ralph lauren polo, louis vuitton, christian louboutin, michael kors outlet online, longchamp outlet, uggs outlet, michael kors outlet online, nike air max, longchamp bags, replica watches, ralph lauren outlet, oakley sunglasses, ray ban sunglasses, louis vuitton outlet online, nike free, michael kors

6:30 PM  
Blogger oakleyses said...

converse shoes outlet, salvatore ferragamo, timberland boots, softball bats, herve leger, ray ban, hollister, louboutin, gucci, nike roshe run, iphone cases, beats by dre, mcm handbags, oakley, p90x workout, insanity workout, wedding dresses, abercrombie and fitch, abercrombie, nike air max, mac cosmetics, babyliss pro, valentino shoes, bottega veneta, mont blanc, converse, jimmy choo outlet, hollister clothing, nike air max, north face outlet, new balance shoes, north face outlet, instyler ionic styler, soccer shoes, lululemon outlet, asics running shoes, ghd hair, giuseppe zanotti, soccer jerseys, nfl jerseys, longchamp uk, reebok outlet, nike air huarache, chi flat iron, hermes handbags, vans outlet, polo ralph lauren, celine handbags, nike trainers uk, vans scarpe

6:34 PM  
Blogger Unknown said...

adidas outlet
soccer jerseys wholesale
michael kors handbags
mulberry outlet store
prada outlet
cheap nba jerseys
ralph lauren uk
swarovski crystal
oakley sunglasses wholesale
chanel handbags outlet
ralph lauren outlet
cheap jordan shoes
canada goose coats
toms outlet store
puma outlet
north face outlet store
ugg boots
black friday deals
ugg outlet
toms outlet
1128minko

6:45 PM  
Blogger xumeiqing said...

151202meiqing
michael kors
ugg slippers
coach factory outlet
coach outlet
cheap toms shoes
mulberry handbags
ugg boots clearance
gucci handbags
air jordan retro
michael kors bag
louis vuitton outlet
louis vuitton
oakley sunglasses
swarovski jewelry
air max 90
cheap oakley sunglasses
coach outlet
north face uk
ugg boots
toms outlet
retro jordans
jordans
oakley sunglasses wholesale
michael kors uk
oakley sunglasses
hollister kids
michael kors handbags
canada goose outlet
polo ralph lauren outlet
michaek kors outlet
oakley sunglasses
ugg boots
nike air max
abercrombie and fitch
ray-ban sunglasses
louis vuitton handbags
louis vuitton
fitflops sale clearance
burberry outlet
michael kors outlet online

5:39 PM  
Blogger John said...

burberry outlet
ugg boots
toms outlet
ugg boots
nike roshe run
ugg outlet
coach outlet online
louboutin pas cher
cheap oakley sunglasses
ugg boots on sale
the north face outlet
nike air force 1
ugg boots
michael kors outlet online
beats by dre
ralph lauren outlet
canada goose
coach outlet online
chanel handbags
michael kors handbags
louis vuitton outlet stores
canada goose outlet
cheap jordans
uggs outlet
michael kors handbags
louis vuitton handbags
louis vuitton outlet
coach factory outlet
abercrombie & fitch
uggs on sale
oakley sunglasses wholesale
polo ralph lauren
20151203yuanyuan

7:14 PM  
Blogger raybanoutlet001 said...

hugo boss outlet
los angeles lakers
chiefs jersey
broncos jerseys
versace shoes
jordan shoes
seattle seahawks jerseys
gucci borse
new england patriots jerseys
ecco shoes

7:01 PM  
Blogger Unknown said...

under armour shoes
ralph lauren polo
jordan shoes
manolo blahnik outlet
levis outlet
michael kors outlet clearance
nike sb stefan janoski
ray ban eyeglasses
michael kors handbags
ray ban sunglasses sale
2017.4.6chenlixiang

12:01 AM  
Blogger raybanoutlet001 said...

skechers outlet
converse shoes
nike huarache
cheap ray ban sunglasses
ray ban sunglasses outlet
moncler outlet
true religion outlet store
kansas city chiefs jerseys
cardinals jersey
ray ban sunglasses
zzzzz2018.4.17

11:02 PM  
Blogger raybanoutlet001 said...

zzzzz2018.5.21
true religion outlet
moncler uk
louboutin shoes
nike factory
vibram five fingers
hermes belt
ralph lauren outlet
ray ban eyeglasses
golden goose shoes
christian louboutin shoes

11:16 PM  
Blogger jjjjjjjjjjjjj said...

yeezy boost 350
yeezy 500 blush
moncler outlet
coach outlet
michael kors factory outlet
nike jordans
off white hoodie
fila shoes
nike react flyknit
moncler

10:59 PM  
Blogger yanmaneee said...

supreme shirt
spongebob kyrie 5
air max 270
supreme clothing
curry 4
lebron 16 shoes
yeezy boost
adidas ultra boost
curry 4
converse outlet

12:42 AM  

Post a Comment

<< Home

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