Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Multiple Compare-Objects not outputting (Stopping after one)

$
0
0

I’m having some issues getting my Compare-Objects to run. Here’s the code:

The CSV is any combination of:

Name "Doe, Jane" "Smith, Jon" "Doe, John" "Johnson, John" 

.

$Users = Import-Csv -Path "users.csv" $System1 = Import-Csv -Path "system1.csv" $System2 = Import-Csv -Path "system2.csv" $System3 = Import-Csv -Path "system3.csv" Compare-Object -ReferenceObject $Users.Name -DifferenceObject $System1.Name -ExcludeDifferent -IncludeEqual | Select-Object @{N='System1'; E={$_.InputObject}} Compare-Object -ReferenceObject $Users.Name -DifferenceObject $System2.Name -ExcludeDifferent -IncludeEqual | Select-Object @{N='System2'; E={$_.InputObject}} Compare-Object -ReferenceObject $Users.Name -DifferenceObject $System3.Name -ExcludeDifferent -IncludeEqual | Select-Object @{N='System3'; E={$_.InputObject}} 

If I run each one individually, they output the intended info. If I try and run more than one, only the first one outputs.

Also, is there any way to dump these into a CSV like this (As viewed in Excel):

System1 System2 System3 Doe, Jane Doe Jane Johnson, John Doe, John 

I’ve tried creating an array but it seems to want to have everything on the same line, like this:

System1 {Doe, Jane, Doe, John, Johnson, John}

submitted by /u/Llamathrust
[link] [comments]

The post Multiple Compare-Objects not outputting (Stopping after one) appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles