Using-
Windows 7 Enterprise SP1 64bit
PSVersion 5.0.10586.117
Build 10.0.10586.117
I am attempting to find the exact sum, maximum, minimum and average sizes (in bytes) of all of the files on the desktop of my user account. I am running the following command -
Get-ChildItem C:\Users\user\Desktop -recurse –File | Measure-Object -property length –sum -Maximum -Minimum –Average | Out-GridView -Title "Max, Min and Avg Size of Each File"
The output comes out as-
count: 28
Average: 7,120.11
Sum: 199,363.00
Maximum: 87,040.00
Minimum: 0.00
Property: Length
However, the properties for my C:\Users\user\Desktop shows the following-
Size: 194 KB (199,645 bytes)
Size on Disk: 284 KB (290,816 bytes)
The Largest file on my desktop is 85.0 KB making the Maximum value result from the code wrong as well.
These numbers clearly do not match. What are the results that i'm getting from the PS command showing? They can't be the actual file sizes. The intended outcome is for the sum to match either the size or size on disk from the properties of my desktop. Please help me understand what my output is and how to get what I need.
Thanks!
gcihas a-Forceparameter. The difference 199,645 - 199,363 = 282 bytes, which is exactly the size of the hiddendesktop.inifile on my desktop. Usingget-childitem -forcemakes the hidden files show up in the results as well, that will probably fix one of your questions. About the biggest file -|sort -property length | select -last 1and see if PS is getting the same file you expect. Exactly what does Explorer show as the full filesize for it?