derLenhart
derLenhart

Reputation: 1

Compare two arrays in PowerShell

I try to compare two arrays, but it doesn't work.

#System.Data.DataSet -> $Dataset.Tables.Identifier
#System.Xml.XmlElement -> $xmlarray

#$Arraytemp = $xmlarray | Where {$Dataset.Tables.Identifier -NotContains $xmlarray.myid}
$Arraytemp = $xmlarray | Where {$Dataset.Tables.Identifier -NotContains $x_}

Write-Host "Compared Results"
$Arraytemp | ft
Write-Host "XML Results"
$xmlarray | ft
Write-Host "SQL Results"
$Dataset.Tables.Identifier | ft

I read a XML result in an array $xmlarray. It contains the column myid as a unique identifier (and other columns).

I read a SQL Server result in an array in $Dataset.Tables.Identifier, it only contains a unique identifier.

The SQL Server result contains only a part of the XML array. So I want to know, which rows are the difference, because I want to INSERT them in the database.

When I check the result with Write-Host the results looks good. When I compare them, nothing happens.

Maybe the data format is not compatible?

Upvotes: 0

Views: 82

Answers (0)

Related Questions