≡ Menu

PowerShell: Query file creation, modification, size, permissions

In this post I am going to detail about querying various file attributes using powershell and some more operations related to that. Get-Item cmdlet helps you to fetch this information. Along with creationtime, it provides some details about the file you are querying. Let us go and see what they are…

Get file creation time:

(Get-item C:localadmincred.xml).creationtime

Get file modification time:

(Get-item C:localadmincred.xml).lastwritetime

Get file size:

"{0:N2}" -f ((Get-item C:localadmincred.xml).length/1mb) + " MB"

Get file extension:

Get-item C:localadmincred.xml | select extension

Get the directory name where file file is located:

dmincred.xml | select directory

Get file Security permissions:

(Get-item C:localdemo.xml).getaccesscontrol.invoke() | select owner -ExpandProperty access



Hope this helps…

Comments on this entry are closed.

  • Chris July 7, 2015, 9:58 pm

    Thanks for this! Just what I needed.