Peter Schneider


MCT, MCSD.NET, MCAD.NET, MCDBA

News

Locations of visitors to this page

  

Austrian .NET Community

Get-DocProps Cmdlet for Powershell

I've written a small and rather simple powershell cmdlet which allows you to list the core and application properties of office documents, so that you can do something like this:

Samples:

Get-DocProps –path "*.docx" | where { $_.Creator –eq "John Doe" }

Get-ChildItem "*.docx" | get-docprops | where { $_.Lines –gt 100 } | select Path,Lines

Get-ChildItem * -include "*.docx","*.xlsx" –recurse | get-docprops | select Path, Creator, Lines, Paragraphs

Get-ChildItem * -include "*.docx" –recurse | get-docprops | measure-object Words,Lines,Paragraphs –sum –min –max -ave

The Cmdlet itself reads the docProps/app.xml and docProps/core.xml files inside Office 2007 documents using the System.IO.Packaging namespace, so therefore install .NET Framework 3.0 to use this cmdlet.

You can download the DocProps Cmdlet here. (No warranty, provided "AS IS", use at your own risk ;-)) If you are interested in the source code just drop me a mail.

After installation just run

add-pssnapin DocProps.Snapin

at your powershell command prompt and enjoy.

Here is a list of the core properties:

Property Name

Type

Category

String

Created

DateTime

Creator

String

Description

String

Keywords

String

Language

String

LastModifiedBy

String

LastPrinted

DateTime

Modified

DateTime

Revision

String

Subject

String

Title

String

Version

String

Word Documents additionally have following properties:

Property Name

Type

Template

String

TotalTime

String

Pages

Int32

Words

Int32

Characters

Int32

Application

String

DocSecurity

String

Lines

Int32

Paragraphs

Int32

ScaleCrop

String

Company

String

LinksUpToDate

Boolean

CharactersWithSpaces

Int32

SharedDoc

Boolean

HyperlinksChanged

Boolean

AppVersion

String

I also run into some implementation, which uses Windows Search to filter for properties.

For several more cmdlets visit the Powershell Community Extensions Project at Codeplex.

Right at the moment there's just a get-docprop cmdlet included in the setup, the set-docprop will follow in a few days, so come back again ;-)

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)