hdsouza
hdsouza

Reputation: 355

Powershell: Combining Arrays

Using PowerShell I need to combine two arrays $IP_Diff and $Line_Diff:

$IP_Diff = "10.1.101.17"
$Line_IP = (@{N="Initialize"}).N |  Select @{N = "Problem_IP";E={$IP_Diff -join ";"}}

$ServerName = "ExServer-01"
$Exist = "False"
$Line_Diff = (@{N="Initialize"}).N |  Select @{N = $ServerName;E={$Exist -join ";"}}

I need the Combined Array to be:

Problem_IP  ExServer-01
----------  -------------
10.1.101.17 False

Upvotes: 0

Views: 48

Answers (1)

mklement0
mklement0

Reputation: 437080

It looks like you're trying to construct a [pscustomobject] instance as follows:

$IP_Diff = "10.1.101.17"
$ServerName = "ExServer-01"
$Exist = "False"

[pscustomobject] @{
  Problem_IP = $IP_Diff
  $ServerName = $exist
}

The above produces the display output shown in your question.

Upvotes: 2

Related Questions