Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been searching far and wide for explicit information on this, but I have not found any at all. Let's say I have a a file or a directory stored in the variable $Item. Using Windows PowerShell (I am using 3.0), how can I get all of the metadata associated with $Item that is not stored in its contents? For instance, I want to get it's permissions, its SID, its time of creation, its time of modification, the time it was last accessed, its attributes, and pretty much anything else that is displayed in the 'Properties' dialog box in Windows Explorer. I need to do this so I can record each item's properties in SVN metadata.

share|improve this question

2 Answers 2

you can get most of those elements from the System.IO.DirectoryInfo class

PS C:\Windows\system32> $([System.IO.DirectoryInfo]"c:\").creationtime
PS C:\Windows\system32> $([System.IO.DirectoryInfo]"c:\").Attributes

...

Here are the properties available from the object: http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx

now, I'm not sure what you mean by recursive, since you said you didn't want the contents of the directory, but you can get a list of sub items using .GetFiles or .GetDirectories. then you can recurse or iterate over them as you like.

share|improve this answer
    
I use the word "recursively" because I need it to cycle through them automatically. –  Melab Mar 13 '13 at 22:27

Assuming:

$item = Get-Item c:\windows\notepad.exe

Last access time:

$item.LastAccessTime.ToString()

Last modification time:

$item.LastWriteTime.ToString()

Creation time:

$item.CreationTime.ToString()

Attributes:

$item.Attributes

Version info:

$item.VersionInfo

The security permissions are not stored in the file, so you have to use the Get-Acl cmdlet:

(Get-Acl $item).Access
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.