justin_grswld
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER