powershell script to get the file size of files in multiple locations

You can run a simple PowerShell script to get the file size of files saved in various locations on a network.


Get-Childitem -file "C:\foofolder\2022.05.31 Fedex Ground.pdf" | select length

Get-Childitem -file "C:\foofolder\Citation\test\XYZ 000400.pdf" | select length

Get-Childitem -file "U:\O'Shea Documents\personal\port st. lucie.heic" | select length


Simply enter the file path in one column of an Excel spreadsheet, with the Get-Childitem -file command in the column to the left, and the | select length operator in the column to the right. Copy the three columns to NotePad and remove the tabs. Enter the script in Windows PowerShell ISE:


It will output the number of bytes in each file. [1924588 equals 1.9 MB]. You can copy the file sizes back into the Excel spreadsheet so they line up with file paths:




Recently, I used this script to get the length of hundreds of Excel files linked to on a spreadsheet for a trial exhibit list that were saved in dozens of different directories, when requested to find if a file was saved on the list under a different Bates number. The closest in size file proved to be a match.