Comments on: PowerShell get file size https://www.spguides.com/check-file-size-using-powershell/ Learn SharePoint, Office 365, Nintex, PowerApps, PowerBI etc, SharePoint training and video courses Tue, 14 May 2024 06:45:45 +0000 hourly 1 https://wordpress.org/?v=6.6.2 By: Jeff Hicks https://www.spguides.com/check-file-size-using-powershell/#comments/51 Wed, 24 Jun 2020 14:48:30 +0000 https://www.sharepointsky.com/?p=771#comment-51 Something to be careful of is that most of the formatting examples you are showing will result in a string. This means if you are using your techniques in a pipelined expression and pipe output to something like Sort-Object, the sort will be on the string which may not be accurate.

Here are other ways to format the number and retain a numeric value that will properly sort.

$size = 256654
$size/1KB
$size/1KB -as [int]
[math]::round($size/1kb,2)

]]>