2

I don't know what's going on with Compare-Object in my Script.

My Compare-Object outputs a perfect output

InputObject                                                                SideIndicator                                                             
-----------                                                                -------------                                                             
@{ComputerName=USSFMW-V03021; CollectionName=}                             ==                                                                        
@{ComputerName=USSFMW-V03013; CollectionName=}                             ==    

Exporting this into an CSV works perfectly

Compare-Object  $alreadyCombs $Computers -IncludeEqual #| Export-CSV $newComptuersCSV

But this :

$test = Compare-Object  $alreadyCombs $Computers -IncludeEqual

results in an empty output:

{@{InputObject=; SideIndicator===}, @{InputObject=; SideIndicator===},

I'm not that long into powershell, and I wonder if I did not understand the logic behind Pipeing and putting the values into a variable.

At the moment, I'm exporting it into CSV, importing it again, deleting CSV... It works good but I can't show this code anybody, that's a pity ....^^

Michael
  • 289
  • 2
  • 5
  • 14

1 Answers1

1

See this answer ...perhaps a similar issue? Your issue can be resolved by piping the compare-object cmdlet to select-object and selecting InputObject and SideIndicator.

Community
  • 1
  • 1
nimizen
  • 3,345
  • 2
  • 23
  • 34