Powershell - diskspace query


I am trying to create a powershell script to query servers and return the drive size and used space but I'm runing into issues..

current script is (attached as well to get round cut/paste issue)

$servers = Get-Content C:\scripts\diskspace\servers.txt
$DriveSize = foreach($server in $servers){
 Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" -computer $server `
 | Select SystemName,DeviceID,VolumeName,`
 @{Name="Used Space(GB)";Expression={[decimal]("{0:N1}"-f(($_.size/1gb)-($_.freespace/1gb)))}},`
 @{Name="Used Space(%)";Expression={"{0:P2}"-f((($_.size/1gb)–($_.freespace/1gb))/($_.size/1gb))}}
$DriveSize | Out-GridView -Title 'Drive Size'
$DriveSize | Export-CSV C:\scripts\diskspace\servers\drive.csv -NoType

Im getting errors related to missing terminators. I want to get this work so I can move on to adding cpu/ram info.

Thanks for any pointers...
Who is Participating?
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.

Can you check the minus sign/hyphen (the second one) in the Used Space calculated property?  It appears to be a long dash instead.

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
ISD-PLCAuthor Commented:
well spotted that fixed it... that has been driving me nuts for ages!

Now to work out how to add a CPU and RAM query....
Luckily attaching the script as you did made it very easy to spot.
ISD-PLCAuthor Commented:
Thanks very much much appreciated.
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.