C
C
CrazyKing2019-05-30 15:25:33
PowerShell
CrazyKing, 2019-05-30 15:25:33

How to get two values ​​from one array into different variables using PowerShell?

I get an array from a JSON file, it looks like this:

D:\test2\o.transform.config  D:\test2\Web.config
D:\test2\o3.transform.config  D:\test2\Web3.config

There may be more values.

Did it like this:
$transformConfigs = $componentSelect.transform_config | Select-Object source, target
Foreach ($transformConfig in $transformConfigs)
{
$transformConfig 
}

Here I get rows one by one in a loop, for example, during the first Foreach pass
D:\test2\o.transform.config D:\test2\Web.config
, I get:
$a = D:\test2\o.transform.config
$b = D:\test2\Web.config

And so on every pass.
How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-05-30
@CrazyKing

$a = $transformConfig.source
$a = $transformConfig | select source
and in general if you have one cycle then why produce the $transformconfig(s) variable?
$componentSelect.transform_config| foreach {$a = $_.source; $b=$_.target}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question