Comparing string in text file to folder path

by Mar 3, 2015

I have a text file which has directory locations, one directory location per line.

What I am trying to do is, loop a set of directories and check if their FullName exists in the said text file.

I tried couple of approaches but I don't seem to be getting the expected result. The below string compare doesn't seem to work, can someone have a look and please let me know if I am going wrong somewhere?

This is what the code looks like:

$TextToWrite="<table border='1'><tr><th align='left'>Directory</th><th align='left'>Deletion Rule</th>"

$rowsInDeleteTextFile= Get-Content "\somedirfilesNames.txt"


$downloadFolders=Get-ChildItem $path | where-object {$_.PSIsContainer -eq $True}

foreach($folder in $downloadFolders)


    if($rowsInDeleteTextFile -contains $folder.FullName)


        Write-Output $folder.FullName + " :  —-> True"

        $TextToWrite+="<tr><td>" + $folder.FullName + "</td><td>True</td></tr>"




        Write-Output $folder.FullName + " :  —-> False"

        $TextToWrite+="<tr><td>" + $folder.FullName + "</td><td>False</td></tr>"




$TextToWrite | out-file "D:Powershellexamplestest.htm"


This is what the filesNames.txt looks like: