PowerTip: Use PowerShell to Find Size of User Profile


Summary: Use Windows PowerShell to find the size of your user profile.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find the size of my user profile and to see the size of the largest file in my profile?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet, recurse through your profile directory, pipe the results to
          the Measure-Object cmdlet, select the Length property, and add Sum and Maximum.
          This command measures the ED directory, and dir is an alias for Get-ChildItem:

PS C:\Users> dir .\ed -Recurse | Measure-Object -Property length -Sum -Maximum

Comments (5)

  1. Joe says:

    OK, how do you do this for a lot of users in the Users folder–not just one? I’m trying to see who is hogging space on a shared server.

  2. Holly says:

    Joe did you figure out how to do it for more than one user at a time?

  3. jim says:

    Hey guys, simply do a foreach loop on all folders within the "users" folder.

  4. John says:

    dir c:users | foreach -begin {} -process{
    $size=(dir $_.FullName -recurse -force -ea silentlycontinue | Measure-Object ‘length’ -sum -Maximum).sum
    write-host("{0:n2}" -f ($size/1MB) +" MB",$_.fullname)
    }

    How do you make this script list in acending order?

  5. james says:

    This doesn’t work everywhere. I’ve tried to run this against some locally cached roaming profiles in the C:Users folder of a terminal server. An exception occurs with the Measure-Object cmdlet saying a length property does not exist for the users profile
    folder. Why don’t they have a length property?

Skip to main content