I am trying to use powershell to get all printers except the ones I have in an exclusion list. Once it has the names, it will update the exclusion list and alert me to the new printers found. However I am unable to filter out the exclusion list, some help on the syntax would be appreciated, or another way to get the same result would be good..
$PrinterServers = Get-ADComputer -f * | Where Name -Like 'SC-PS-0*'
$ExcludeList = Get-Content .myExcludedPrinters.txt
$ExcludeList = $ExcludeList -Join '|'
$PrinterReport = ForEach($ps in $PrinterServers){
Get-Printer -ComputerName $ps.Name | Where {$_.Name -notlike '*Redirected*' -and $_.Name -notmatch $ExcludeList} | Select ComputerName, Name, PortName, Location, Comment, Shared
}
The $PrinterReport should return 1 printer newly installed on two printservers