how to pass argument with surrounded by single quotation to powershell

Hi
could you help please

How to pass a string value surrounded by single quotation to powershell and use the string inside powershell as it is. Basically, I'm trying to find/replace string in a text file.

From caller batch file
please note. I'm passing 'wf1','wf2','wf3'
powershell -noprofile -executionpolicy bypass -file "E:\\update_listl.ps1 'wf1','wf2,'wf3'"

Open in new window


In Powershell script
$workflow_list=$args[0]
Write-Host $workflow_list
(Get-Content E:\scripts\test.txt) | ForEach-Object { $_ -replace "LIST_OF_WF", $workflow_list } | Set-Content E:\scripts\test2.txt

Open in new window


test.txt content
PROC_NAME in (LIST_OF_WF) few more string XXXXXXXXXXXXXXXXXXX

Open in new window


Current output in test2.txt without single quotation
PROC_NAME in (wf1 wf2 wf3)  few more string XXXXXXXXXXXXXXXXXXX

Open in new window


Expected is
PROC_NAME in ('wf1','wf2','wf3')  few more string XXXXXXXXXXXXXXXXXXX

Open in new window


Thanks in advance
enthuguyAsked:
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.

enthuguyAuthor Commented:
Looks like we need to use escape char ` for single quotation and comma.....and it worked fine...thanks anyway

powershell -noprofile -executionpolicy bypass -file "E:\\update_listl.ps1 "`'wf1`'`,`'wf2`'`,`'wf3`'""

Open in new window

0

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
Pawan KumarDatabase ExpertCommented:
You need to use the escape character for single quote.
1
Pawan KumarDatabase ExpertCommented:
Oh... you beat me. :)

Cheers.
0
enthuguyAuthor Commented:
Thanks anyway Pawan, much appreciated
1
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
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.