Author Posts

January 1, 2012 at 12:00 am

by Lembasts at 2013-04-02 17:37:51

Greetings,

Let's say I had a 'Master' collection that contained a computername property and dozens of other properties.
Then let's say I had a 'transaction' collection that contained a computername property and dozens of other properties.

I want to remove all instances in the 'Master' collection where the computername matches one that exists in the 'transaction' collection. (For this comparison I dont care about the other properties)
All 'Master' collection properties for the remaining instances need to be preserved.

I have tried some nasty coding loops to achieve this but im wondering what would be the most efficient way of coding this?

by mjolinor at 2013-04-02 17:52:51

I'd think this would work:

$computerlist = $transactions |
select -ExpandProperty computername -Unique

$Newmaster = $master |
where {$computerlist -notcontains $_.computername}

by Lembasts at 2013-04-02 17:56:42

Thanks heaps. I was trying something with notcontains but I couldnt get a straight list of computernames. It was the expandproperty that I needed!!!