Powershell Search with slash

The script below was created to search thru file to find occurrences. I need  
to find Instances of the search string below since I am looking for connection string in SSIS.

My issue is that the search string does not work because it has a "\" in the string. I need the search to work with the slash in my search string.

$RootString = "C:\Temp\"
$FileName = Get-ChildItem $RootString  -recurse | Select-String -pattern $SearchString | group path | select name

$FileName | Out-GridView

$FileName | Out-file -width 300 -filepath "C:\Users\ltorres\Desktop\pshellOutPut_SP3.txt"

Open in new window

Leo TorresSQL DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

why not just escape it:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Or use -SimpleMatch with select-string to switch off RegEx evaluation.

$FileName = Get-ChildItem $RootString  -recurse | Select-String -pattern $SearchString –simplematch | group path | select name
Fernando SotoRetiredCommented:
Hi ltorres321;

In Windows PowerShell an expression with a \ is interpreted as the start of a regular expression. So that PowerShell does not interpret thee \ character to be a regular expression escape it as @becraig has suggested by doubling up on the character as so \\.

The PowerShell the escape character is the grave-accent(`) . For example the following `n = new line, `r = carriage return, `t = horizontal tab and so on.
Leo TorresSQL DeveloperAuthor Commented:
I didn't know I could use \\.. But learning simple match will be nice.. can you show a quick sample
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.