Concat variable's name in powershell [duplicate] - powershell

This question already has answers here:
Dynamically create variables in PowerShell
(1 answer)
Create an incrementing variable from 2 variables in PowerShell
(2 answers)
Closed 10 months ago.
I looking for this in powershell
$VAR0=args[0]
$VAR1=args[1]
$VAR2=args[2]
With a construction like this
$a=0
$VAR+$a=args[$a]
but I cannot concatenate this way

Related

Powershell how to replace multiple commands with output of single variable [duplicate]

This question already has answers here:
Access PSObject property indirectly with variable
(3 answers)
Set Value of Nested Object Property by Name in PowerShell
(3 answers)
Closed 2 months ago.
I am traversing an object and would like to replace several path parts with a string stored in another variable. For example:
# a is a complex ps object, the path is valid
$a.b.c
myvalue
$replace = "b.c"
$a.$($replace)
# here I expect 'myvalue', however nothing is returned, as I would like to execute the equivalent of $a.b.c
Is there some way to do this replacement?

Why does wrapping output in quote create extra quote after? [duplicate]

This question already has answers here:
.* matches 2 times
(2 answers)
Why do regex engines allow / automatically attempt matching at the end of the input string?
(6 answers)
Closed 6 months ago.
I want to ls -name a folder and wrap the result between the quotes`. However the result make an extra quote after.
> (ls -name) -replace '(.*)', '"$1"'
"apple"""
"orange"""
"dog"""
"cat"""
Why is that?

Why does order of operands matter when adding powershell strings and arrays? [duplicate]

This question already has answers here:
Why do integers in PowerShell compare by digits?
(4 answers)
Closed 4 years ago.
In powershell, when I add string + array the result is a string, but when I add array + string the result is an array? Why is that?
PowerShell converts the second operand to the type of the first operand (if it can).

Count number of occurrence of pipe ("|") in a file with PowerShell [duplicate]

This question already has answers here:
Counting characters in a specific text file
(4 answers)
Closed 4 years ago.
I have data in a file like below.
text1|text2
text3|text4|
I'm looking for a Power Shell command to count number of pipes present in thisfile.
Normally I would want you to show some effort but this is trivial enough I won't bother:
$pipeCount = (get-content file.txt -Raw).Split('|').count - 1
$pipeCount

using wildcard in Perl in dir name matching [duplicate]

This question already has answers here:
using wildcard in the dir locations and find all files with an extension
(2 answers)
Closed 9 years ago.
my #hex_locations = ("$FindBin::Bin/../../../project/platform-aa-full/bb",
"$FindBin::Bin/../../../project/platform-aa-base/bb");
how do I use wild card to match any directory with project/platform-aa-* in above code?
Use glob
my #hex_locations = glob("$FindBin::Bin/../../../project/platform-aa-*/bb");