the goal of my script is to copy some files. i import a config file, which gives me the path and a filename for an exclude (the exclude shouldnt get copied).
now, i have 2 arrays, one for the folders and one for the excludes and i want to delete all rows from the array1 which contain the exclude file from array2.
i tried something like this but it has not worked...
$arrFolder = $arrFolder - $arrExcludes
$arrFolder | $_ -replace "$arrExcludes",""
You can also use Except from LINQ (PS 3.0+):
$arr1 = "Folder1", "Folder2", "Folder3", "Folder4" $arr2 = "Folder2", "Folder3" [System.Linq.Enumerable]::Except([string]$arr1, [string]$arr2)