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

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -