title: Powershell: Get Size of Windows User Directory (C:\Users\<UserName>)
body: <p>I need to get the size of all user folders across 200 VMs. I need -force to see the hidden folders of other users. </p>
  
  <pre><code>$objFSO = New-Object -com  Scripting.FileSystemObject 
  "{0:N2}" -f (($objFSO.GetFolder("C:\users").Size) / 1MB) + " MB"
  </code></pre>
  
  <p>Works fine for C:\Temp, for example, but returns 0.00 MB for C:\Users, even on my local, where I am an admin. </p>
  
  <pre><code>Get-ChildItem -path c:\users -force -recurse | Measure-Object length -sum
  </code></pre>
  
  <p>Throws security exceptions--even on my own user folder, with admin, running in an elevated PS session. </p>
  
  <pre><code>+ CategoryInfo          : PermissionDenied: (C:\Users\YuriPup\Documents\My Music:String) [Get-ChildItem], UnauthorizedAccessException
  + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
  </code></pre>