![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Compare two array Hi all, I have two identical arrays. $a = 0,1,2,3 $b = 0,1,2,3 I need to know if the arrays is identical if ($a -eq $b) this is doesn't working Thanks, Didi |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Compare two array I believe you can use compare-object. "Did" <didi10000@walla.co.il> wrote in message news:1173698692.087060.208650@64g2000cwx.googlegroups.com... > Hi all, > I have two identical arrays. > $a = 0,1,2,3 > $b = 0,1,2,3 > > I need to know if the arrays is identical > > if ($a -eq $b) this is doesn't working > > Thanks, > Didi > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Compare two array I have used compare-object successfully.$a = 1,2,3 $b = 1,3,4 $c = compare-object $a $b $c write-host "Objects inly exist in the first file" $c | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} write-host "Objects inly exist in the second file" $c | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} $a = "a","b","c" $b = "a","c","d","e" $d = compare-object $a $b $d write-host "Objects only exist in the first file" $d | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} write-host "Objects only exist in the second file" $d | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} regards, ktmd "Brandon Shell" wrote: > I believe you can use compare-object. > > "Did" <didi10000@walla.co.il> wrote in message > news:1173698692.087060.208650@64g2000cwx.googlegroups.com... > > Hi all, > > I have two identical arrays. > > $a = 0,1,2,3 > > $b = 0,1,2,3 > > > > I need to know if the arrays is identical > > > > if ($a -eq $b) this is doesn't working > > > > Thanks, > > Didi > > > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Compare two array FYI, when two arrays are the same, compare-object returns null. ktmd "ktmd" wrote: > I have used compare-object successfully.$a = 1,2,3 > $b = 1,3,4 > $c = compare-object $a $b > $c > write-host "Objects inly exist in the first file" > $c | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} > > write-host "Objects inly exist in the second file" > $c | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} > > > $a = "a","b","c" > $b = "a","c","d","e" > $d = compare-object $a $b > $d > > write-host "Objects only exist in the first file" > $d | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} > > write-host "Objects only exist in the second file" > $d | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} > > regards, > ktmd > > > > > "Brandon Shell" wrote: > > > I believe you can use compare-object. > > > > "Did" <didi10000@walla.co.il> wrote in message > > news:1173698692.087060.208650@64g2000cwx.googlegroups.com... > > > Hi all, > > > I have two identical arrays. > > > $a = 0,1,2,3 > > > $b = 0,1,2,3 > > > > > > I need to know if the arrays is identical > > > > > > if ($a -eq $b) this is doesn't working > > > > > > Thanks, > > > Didi > > > > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare paths | RickB | PowerShell | 4 | 04-30-2008 07:16 AM |
| compare users in csv to AD | Niro | PowerShell | 2 | 12-26-2007 01:09 PM |
| how to compare in this situation | IT Staff | PowerShell | 10 | 07-22-2007 08:32 AM |
| how to assign values to array and how to create array via variable | Frank | PowerShell | 1 | 03-13-2007 05:18 PM |
| How can I compare two DVDs? | Chris | Vista General | 1 | 09-26-2006 05:16 AM |