Link to home
Start Free TrialLog in
Avatar of justin_grswld
justin_grswldFlag for United States of America

asked on

Powershell script question

I am working on putting together a script that will generate an html report on disk space usage on our Windows servers.  I am having troubles with the script giving me an error on a section of the script stating "Assignment expression is not valid.  The left hand side of an assignment operator needs to be something that can be assigned..."  
here is the section of the script:
foreach($disk in $disks)
 {        
  $deviceID = $disk.DeviceID,
  $volName = $disk.VolumeName,
  $size = $disk.Size,
  $freespace = $disk.FreeSpace,  
  $percentFree = [Math]::Round(($freespace / $size) * 100, 2),
  $sizeGB = [Math]::Round($size / 1073741824, 2),
  $freeSpaceGB = [Math]::Round($freespace / 1073741824, 2),
  $usedSpaceGB = ($sizeGB - $freespaceGB), <-- This is the problem
  $color = $whiteColor;

If I replace the commas with semi-colons at the end of each line, the script will run but it will only capture one server and only one of its drives.  I am new to powershell scripting so I am a little stuck.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany 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 justin_grswld

ASKER

Thank you for the fast response on this.  You pointed me in the right direction.  I had to modify this script a touch, but was able to make it work.  Thank again.
Of course you had to modify it, since you did not post a complete script :p. But this is even better, as it shows you were able to digest what I was presenting.