Creating a dynamically-named variable in PowerShell -
i'd create variable offsetx
, x
number. right now, use:
new-variable -name offset$i
where $i
integer. however, want offset($i-1)
. how change syntax of above statement accomplish this?
my latest attempt was:
new-variable -name offset+"[int]$i-1"
which didn't result in error being thrown, still doesn't accomplish goal.
put subtraction part inside $(...)
, known subexpression operator.
below demonstration:
ps > $i = 2 ps > new-variable -name offset$($i - 1) -value value ps > $offset1 value ps >
Comments
Post a Comment