I'm doing a very basic script of sorting an employee CSV file, and renaming a couple of the fields. Easy stuff, but now I'm supposed to add a column at the end and show what the employee's 6% bonus would be. So I'm using this entry:
@{label='Bonus';expression={$_.Salary * .06}}
However..it just returns nothing. The field is blank. If I change it to show the bonus plus the salary...
@{label='BonusSalary';expression={$_.Salary * 1.06}}
It returns the Salary value, like I multiplied by one. Now if I change the operator to anything OTHER than multiplication, it works fine.
Can someone point me in the right direction to find out why it's doing this?
I'm assuming this is the situation, where the left argument is a string. In that case, powershell will repeat the string that many times. The right arg actually becomes an integer. If you reverse the arguments, it will convert the right argument to a double or floating point. When you import a csv, all fields are strings. It would be different with a json file.
'1.0' * .06
.06 * '1.0'
0.06
'hi' * 3
hihihi
'1.0' * 3
1.01.01.0
[double]'10.00' * .06
0.6