Finding all *pst and *.doc files on the c:drive from a list of computers

rated by 0 users
This post has 1 Reply | 1 Follower

Top 500 Contributor
Posts 13
kanoute696 Posted: 03-29-2012 10:13 AM

Hi All, I'm a beginner (Im sure you hear that all the time!)

I'm looking to do this step by step so i understand how it all works, thanks in advance for the help. 

Outcome: Powershell to look at a list of computers in a text file, search only their C:drive's, for file extensions *.pst and *.doc and output a list to a csv file with columns computername, filename, path, size, and also specifying if the computer cannot be found or if no such file exists on the computer. 

To start and to get the basics correct , should I use

get-wmiobject -query "Select * from CIM_DataFile Where Extension = 'pst'" -ComputerName (Get-Content C:\scripts\computernames.txt)

The problem here - is it searches all of the mapped drives - I just want the c:drive's and I'm not sure where to go after this

I cant use get-childitem as the group policy in our company doesn't permit even admin to get this detail. 

I am really just looking for a concrete start as I keep coming up against a brick wall ... 

 

Thank you 

Top 25 Contributor
Posts 296
Microsoft MVP
Top Contributor

Add the drive as part of the WHERE clause

Get-WmiObject -Query "SELECT * from CIM_DataFile WHERE Drive = 'C:' AND Extension = 'doc'"

or

Get-WmiObject -Query "SELECT * from CIM_DataFile WHERE Drive = 'C:' AND Extension = 'pst'"

Page 1 of 1 (2 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.