Powershell Disk space on all folders on drive

Does anyone have a script that works in powershell Windows Server 2008 R2, that gives me the folder space on 2 drives.

I need the folder size:   Total size of folder, remaining size of folder.
All folders on a particular drive.

I tried some scripts but either they did not work, or did not give me what I needed.

I know very little about powershell.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

From what you are asking for sounds impossible given the remaining space is on the drive not the folder.
Your question seems to suggest you use file share resource handler that sets a quota for a folder and you are looking for powershell mechanism that will report that info while running locally.
Presumably the scripts you've seen deal with reporting the folder sizes as you want, using a list with your set limits on the various folders will let the script you have seen to calculate the remaining space for those folders.
zero000koolAuthor Commented:
No quotas involved.

I just want the disk space taken and remaining on the folders on the root C:\ or E:\, what your telling me is this is impossible?
The remaining space is reflected as free space on the drive not on the individual folders.
You can see the aggregate space consumed on the drive, or go through getting the space consumed on each folder.

powershell has access to the wmi interface as well
DBAduck - Ben MillerPrincipal ConsultantCommented:
WMI is the way to go for what you want.  The Win32_LogicalDisk or the Win32_Volume are the objects that you can use to see the Capacity and Free Space.

Get-WmiObject -Class Win32_LogicalDisk -ComputerName computer | Where-Object { $_.DriveType -eq 3 } | 
Select Name, Size, FreeSpace | ft * -auto

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zero000koolAuthor Commented:
from the command can you have the output to GB or KB?
It does what I want but want the space in KB, or GB

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.