How to Get File Details and File Version in PowerShell

To get the details of a file in PowerShell, use Get-Item with the file path. It returns the name, size, dates and attributes, and Format-List shows them one per line:

Get-Item -Path C:\psfaqs\Reports\q3-sales.csv |
    Select-Object -Property Name, Length, CreationTime, LastWriteTime, Attributes |
    Format-List

Output:

Name          : q3-sales.csv
Length        : 3314
CreationTime  : 7/1/2026 8:00:00 AM
LastWriteTime : 9/15/2026 10:30:00 AM
Attributes    : Archive
PowerShell Get-Item shows the details of a file
Name, size, dates and attributes of a file (PowerShell 7)

Length is the size in bytes. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1, and they returned the same results.

Read one property at a time

Save the file object in a variable, then read the properties you need. Here I also turn the size into KB and format the date:

$file = Get-Item -Path C:\psfaqs\Reports\q3-sales.csv

"Folder:     $($file.DirectoryName)"
"Extension:  $($file.Extension)"
"Size:       {0:N1} KB" -f ($file.Length / 1KB)
"Modified:   $($file.LastWriteTime.ToString('MMMM d, yyyy h:mm tt'))"
"Days since: $(((Get-Date).Date - $file.LastWriteTime.Date).Days)"

Output:

Folder:     C:\psfaqs\Reports
Extension:  .csv
Size:       3.2 KB
Modified:   September 15, 2026 10:30 AM
Days since: 13

Get-ItemProperty returns the same object for a file, so either cmdlet works. Microsoft lists the options in the Get-Item documentation.

PropertyWhat it holds
LengthSize in bytes
CreationTimeWhen the file was created on this drive
LastWriteTimeWhen the content last changed
LastAccessTimeWhen it was last read, if Windows tracks it
DirectoryName / ExtensionThe folder path and the extension

A copied file gets a new CreationTime, but keeps its LastWriteTime. That’s why a file can look “modified” before it was “created”.

Check file attributes

Attributes lists every flag on the file. For a quick yes or no, use IsReadOnly or HasFlag:

$file = Get-Item -Path C:\psfaqs\Reports\readme.txt

"Attributes: $($file.Attributes)"
"Read-only:  $($file.IsReadOnly)"
"Hidden:     $($file.Attributes.HasFlag([System.IO.FileAttributes]::Hidden))"

Output:

Attributes: ReadOnly, Archive
Read-only:  True
Hidden:     False

How do I get the version of a file?

Executables and DLLs carry version details. Get-Item returns them in the VersionInfo property:

$info = (Get-Item -Path "$env:WINDIR\System32\robocopy.exe").VersionInfo

"Description:    $($info.FileDescription)"
"FileVersion:    $($info.FileVersion)"
"ProductVersion: $($info.ProductVersion)"
"FileVersionRaw: $($info.FileVersionRaw)"

Output:

Description:    Microsoft Robocopy
FileVersion:    10.0.26100.1 (WinBuild.160101.0800)
ProductVersion: 10.0.26100.1
FileVersionRaw: 10.0.26100.9278
PowerShell VersionInfo FileVersion vs FileVersionRaw for an exe
The FileVersion text and the real version differ (Windows PowerShell 5.1)

Look at the two versions. On Windows system files, the FileVersion text often shows the original build number, while FileVersionRaw shows the version of the file that’s actually installed.

FileVersionRaw is a real version object, so it’s also the one to sort and compare. The FileVersion text can include extra words in brackets.

Get the version of several files

Get-ChildItem -Path "$env:WINDIR\System32\cmd.exe", "$env:WINDIR\System32\robocopy.exe" |
    Select-Object -Property Name, @{ Name = 'Version'; Expression = { $_.VersionInfo.FileVersionRaw } }

Output:

Name         Version
----         -------
cmd.exe      10.0.26100.9278
robocopy.exe 10.0.26100.9278

Compare a file version

$version = (Get-Item -Path "$env:WINDIR\System32\robocopy.exe").VersionInfo.FileVersionRaw

if ($version -ge [version]'10.0.26100.0') { "Version $version is 10.0.26100 or later" }

Output:

Version 10.0.26100.9278 is 10.0.26100 or later

Comparing [version] objects works number by number, so 10.0.9 is correctly lower than 10.0.10.

Get a file hash

A hash tells you if two files are identical or if a download was changed. Get-FileHash uses SHA256 by default:

Get-FileHash -Path C:\psfaqs\Reports\readme.txt -Algorithm SHA256 |
    Select-Object -Property Algorithm, Hash

Output:

Algorithm Hash
--------- ----
SHA256    D295093D2C163561541717572F743D1D2BCEE3E82774088A9882BBDC63C32DF6
PowerShell Get-FileHash returns the SHA256 hash of a file
The SHA256 hash of a file (PowerShell 7)

Compare it with the hash the publisher lists. The Get-FileHash documentation covers the other algorithms.

Save the details of every file in a folder

Get-ChildItem returns the same file objects for a whole folder, so you can pick columns and export them:

Get-ChildItem -Path C:\psfaqs\Reports -File |
    Select-Object -Property Name, Length, LastWriteTime |
    Export-Csv -Path C:\psfaqs\file-report.csv -NoTypeInformation

Get-Content -Path C:\psfaqs\file-report.csv

Output:

"Name","Length","LastWriteTime"
"budget-2026.xlsx","5120","8/3/2026 2:05:00 PM"
"q3-sales.csv","3314","9/15/2026 10:30:00 AM"
"readme.txt","39","7/1/2026 9:00:00 AM"

To get just the count and the total size, pipe the files to Measure-Object:

$stats = Get-ChildItem -Path C:\psfaqs\Reports -File | Measure-Object -Property Length -Sum
"$($stats.Count) files, {0:N1} KB in total" -f ($stats.Sum / 1KB)

Output:

3 files, 8.3 KB in total

See how to get a file size in PowerShell for sizes in MB and GB.

Frequently Asked Questions

How do I get file details in PowerShell?

Use Get-Item -Path C:\Folder\file.txt | Format-List * to see every property, or pick the ones you need with Select-Object.

How do I get the version of an exe with PowerShell?

Use (Get-Item -Path app.exe).VersionInfo.FileVersionRaw. It gives the real version, which you can compare with [version].

Why do FileVersion and FileVersionRaw show different numbers?

FileVersion is a text field the developer fills in, and Windows system files often keep the original build there. FileVersionRaw is read from the file’s version numbers.

How do I get a file’s last modified date in PowerShell?

Use (Get-Item -Path file.txt).LastWriteTime. Format it with .ToString('MMMM d, yyyy') for a friendly date.

How do I check if a file is read-only in PowerShell?

Use (Get-Item -Path file.txt).IsReadOnly. It returns True or False.

More file guides you might need: