PowerShell Script to compare two lists

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}


Leave a reply:

*

*

Your email address will not be published. Required fields are marked *