Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

"Not enough )'s"???

$
0
0

Those of you who work with Windows 7 might know about the wonderful UNhelpful feature Microsoft added where if you plug in a USB Printer, if it's the same type of printer that was on the PC before, it will create the printer for you, but with the same name and a "(Copy 1)", "(Copy 2)", etc tacked on to the end of the printer name.  This sometimes happens when just reseating the cable from the printer to the PC.  I have offsite locations with 40 "(Copy)" printers.

I am writing a Powershell script to try and get all the copy printer names on a PC, sort them, then delete all but the last printer in the list - but I'm running into a problem here -

Select-String StorePrinters.txt -Pattern "PS3 (Copy" | ForEach-Object {$_.Line} > CopyLexmarkPrinters.txt

This should put any "Copy" printer into the new text file, but instead, I'm getting the error:

Select-String : parsing "PS3 (Copy" - Not enough )'s

I'm guessing Powershell is looking for a closed parenthesis, even though that's part of the string I need to search for.

Is that what's going on here?  When I remove that ( it doesn't return any errors - but it also doesn't return the list of printers I need because the printer has that ( in the printer name.


Viewing all articles
Browse latest Browse all 6937

Trending Articles