Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

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!
Avatar of rlandquist
rlandquist
Flag of United States of America image

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

ASKER CERTIFIED SOLUTION
Avatar of rlandquist
rlandquist
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samiam41

ASKER

Smart man!  There is so much to learn.  Thanks for finding it.  Testing it now.
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
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!