• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 954
  • Last Modified:

powershell command to get directory size of remote pc of files over x mb

Hi Experts.  I am getting more familar with powershell and the more I use/test with it, the more I like it.  Since there is a computer in our environment that is showing it has less than 25% disk space left (thanks SpiceWorks for the warning), I would like to use powershell to run a quick audit to tell me what file(s) may be blowing up.  

I ran dir \\pc\c$ -r and the list of files and their sizes just kept going and going.  Would one of you that know what switch I am missing kindly tell me how to filter out file sizes that are less than 10mb or are over 10mb (which ever is easier), please?  

Your help is greatly appreciated.  Thanks!
0
samiam41
Asked:
samiam41
  • 3
  • 2
1 Solution
 
rlandquistCommented:
This is a way to list the largest X number of files, so not exactly what you are asking for, but maybe it will work for what you are trying to do.

It will take a while as it reads every file, but when it is done it will only show you the largest 20 files.  You can change the 20 to whatever you want.
dir \\pc\c$ -r|sort-object -descending|select -first 20

Open in new window

0
 
rlandquistCommented:
I just found the syntax for what you want to do:
dir \\pc\c$ -r|Where-Object {$_.Length -gt 10MB}

Open in new window

0
 
samiam41Author Commented:
Smart man!  There is so much to learn.  Thanks for finding it.  Testing it now.
0
 
samiam41Author Commented:
Outstanding!

It would be great to work with you again.  BTW, where is the best place/site to learn Powershell?  I'm hitting up the technet site but wanted to ask if you knew of other good sites.

Thanks again
0
 
rlandquistCommented:
There are so many....
Best thing to do is Google Powershell and whatever you are trying to do.

Thanks for the grade, and I look forward to working with you again!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now