Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pull last saved info from a file.

841 views
Skip to first unread message

Shawn

unread,
Jul 24, 2008, 11:38:07 AM7/24/08
to
What powershell command would I use to pull file properties (Last saved by)
of all files in a directory?

I am new to Powershell so forgive me!

Shawn

Marco Shaw [MVP]

unread,
Jul 24, 2008, 12:04:29 PM7/24/08
to

Is that for properties inside an Office document?

Marco

--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com

Shay Levy [MVP]

unread,
Jul 24, 2008, 1:04:32 PM7/24/08
to
Hi Shawn,


Is 'Last saved by' equel to 'LastModified' ? If so:


PS > dir c:\foo.txt | select Name,lastWriteTime


You can find any object properties by piping the object to get-member cmdlet:


PS > dir c:\foo.txt | get-member -member property,noteproperty

TypeName: System.IO.FileInfo

Name MemberType
---- ----------
PSChildName NoteProperty
PSDrive NoteProperty
PSIsContainer NoteProperty
PSParentPath NoteProperty
PSPath NoteProperty
PSProvider NoteProperty
Attributes Property
CreationTime Property
CreationTimeUtc Property
Directory Property
DirectoryName Property
Exists Property
Extension Property
FullName Property
IsReadOnly Property
LastAccessTime Property
LastAccessTimeUtc Property
LastWriteTime Property
LastWriteTimeUtc Property
Length Property
Name Property

To see the ALL (*) properties and the values pipe the object to format-list

dir c:\foo.txt | format-list *


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic

S> What powershell command would I use to pull file properties (Last
S> saved by) of all files in a directory?
S>
S> I am new to Powershell so forgive me!
S>
S> Shawn
S>


Shawn

unread,
Jul 24, 2008, 12:16:00 PM7/24/08
to
Yes. The last modified by name is what I am after. Thanks!

Shawn

unread,
Jul 24, 2008, 2:45:00 PM7/24/08
to
Thanks! Can you do this for WHO last modified it?

Shawn

Shay Levy [MVP]

unread,
Jul 24, 2008, 4:32:48 PM7/24/08
to

For ANY file type you'll have to enable auditing and poll the security event
log. If there's such property for Office files
then the Dsofile.dll com component may help you get it:

http://support.microsoft.com/kb/224351


---
Shay Levy
Windows PowerShell MVP

blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic

S> Thanks! Can you do this for WHO last modified it?
S>
S> Shawn
S>
S> "Shay Levy [MVP]" wrote:
S>

Kiron

unread,
Jul 24, 2008, 9:20:05 PM7/24/08
to
I got this filter that adds a 'LastModifiedBy' NoteProperty to any
[IO.FileInfo] object with an Extension property of .doc, .docx, .docm --only
for Word documents:

filter Add-LastModifiedBy {
begin {$wd = new-object -c word.application}
process {
if ($_.extension -match '\.doc[mx]?') {
$doc = $wd.documents.open($_.fullName, $false, $true)
[xml]$ooxml = $doc.wordOpenXML
$nsm = new-object xml.xmlNamespaceManager $ooxml.nameTable

$nsm.addNamespace('cp','http://schemas.openxmlformats.org/package/2006/metadata/core-properties')
$lastModBy = $ooxml.selectSingleNode('//cp:lastModifiedBy', $nsm).'#text'
$doc.close([ref]$false)
add-member noteProperty LastModifiedBy $lastModBy -in $_ -pass
}
}
end {
$wd.quit()
# release resources
rv wd, doc, nsm -ea 0
}
}

ls ~\Documents | Add-LastModifiedBy | ft fullname, lastmodifiedby -a
$docs = ls ~\Documents | Add-LastModifiedBy
$docs | ft fullname, lastmodifiedby -a

--
Kiron

0 new messages