PowerTip: Find Largest File in User Profile with PowerShell

PowerTip: Find Largest File in User Profile with PowerShell

  • Comments 3
  • Likes

Summary: Use Windows PowerShell to find the largest file in your user profile.

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

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet (dir is an alias for the Get-ChildItem), do a recursive search
          of your user profile directory, then sort the files by size and select the last file:

dir $env:USERPROFILE -Recurse -File | sort length | select -last 1

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Great command!
    is there anyway to convert the bytes to MB or GB? not a huge deal, just more human readable

  • @Bruce: Try :
    dir $env:USERPROFILE -Recurse -File | sort length | select -last 1 | select name, @{LABEL='GBfreespace';EXPRESSION
    ={$_.length/1MB} }