views:

274

answers:

2

Can I search a drive to show all documents that were created by a particular user? I figured powershell is the way to go...but perhaps another approach is possible?

Basically, I want to search a drive and find all *.doc or *.docx files and access the word properties to view who created the file (author).

+2  A: 

In that case you would need to open all Word documents with Word itself, using the COM object Word.Application. Then you can look at the document's metadata using the ContentTypeProperties collection on the Document object. The author name, if present, would be in that collection.

This will take a while, however, so maybe you could just take a look at the file system ACLs to determine who created the file? But that tells you only the user who created the file, not the person who created the document.

Another option would probably be to use Windows Search from within Powershell. Apparently you can use it with an OLE DB provider. And I think Windows Search is able to query author information from Word documents.

Joey
Couldn't I use System.IO.FileInfo from within powershell (or just straight c#) to look at the file properties in a folder?
And what will you read from that? Go ahead, but author, etc. are metadata specified differently for every file format that supports them. Those are not file system metadata. So using a FileInfo (which is what Powershell gives you anyway with Get-ChildItem) won't help you here. _Unless_ you actually want to use the creator's user name, not the author name specified in the document itself.
Joey
Good point. http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug08/hey0813.mspx looks to be the solution, yet I can't get it to work
+1  A: 

Take a look at this blog post. It has a bit more PowerShelly way of doing this. :-)