AnoopGeorge.com

PowerShell Script to compare two lists

22.12.2008

Blog

A quick script to compare two arrays.

$arrFirst = get-content First.txt
$arrSecond = get-content Second.txt

New-Item “C:MyworkplacepsFirstInSecond.txt” -Type file
New-Item “C:MyworkplacepsFirstNotInSecond” -Type file

Foreach ($First in $arrFirst)
{
If ($arrSecond -contains $First)
{Add-content “C:MyworkplacepsFirstInsecond.txt” $First}
Else
{Add-content “C:MyworkplacepsFirstNotInSecond.txt” $First}

TAGS:

You must be logged in to post a comment.