Variable (for Windows/Powershell) that contains a character which must by escaped?

16 views
Skip to first unread message

Matt Gagliardi

unread,
Aug 7, 2016, 8:38:47 PM8/7/16
to Ansible Project
I searched around but didn't see anything that appeared to apply to the Windows/Powershell application I need advice on.  I've got a playbook that works 100% fine *as long as a certain variable doesn't contain a "$" character*.  I realize the issue is that Powershell is interpreting that and dropping the "$" and everything after it.  Is there any way to escape a variable such that it'll be interpreted simply as a string?  Right now what I'm doing is using the raw module and the command looks like this:

raw: 'echo some information here: {{ variable1 }} \\ {{ variable2 }} {{ variable3 }} > C:\test.txt'

Let's say it's the second variable that should be Test$123...what I'm getting output to that file is simply Test.  I've tried adjusting quote position and type (single vs. double, etc.) and I'm guessing I just haven't hit on the right combination...but I'd really appreciate any help.

Matt Davis

unread,
Aug 8, 2016, 1:52:07 PM8/8/16
to Ansible Project
Tried the stop-parsing symbol ( --% )? https://technet.microsoft.com/en-us/library/hh847892.aspx
Reply all
Reply to author
Forward
0 new messages