# Passing databag value with special characters to powershell block

**URL:** <https://discourse.chef.io/t/passing-databag-value-with-special-characters-to-powershell-block/11398>\
**Category:** Chef Infra (archive)\
**Created:** [August 29, 2017, 5:37pm UTC](https://discourse.chef.io/t/passing-databag-value-with-special-characters-to-powershell-block/11398 "2017-08-29T17:37:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bab5470](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bab5470](https://discourse.chef.io/u/bab5470)\
**Post date:** [August 29, 2017, 5:37pm UTC](https://discourse.chef.io/t/passing-databag-value-with-special-characters-to-powershell-block/11398/1 "2017-08-29T17:37:32Z")

</div>

I have a value in a databag with a special character in it (a dollar $ sign). In my default.rb file I’m getting the value

string = data\_bag\_item(‘strings’, ‘mystring’)[‘value’]

Then later in my recipe I have the following:

powershell\_script ‘script’ do  
code \<\<-EOH  
write-host " ‘#{string}’ "  
EOH  
end

If my string was some$tring what I end up seeing is “some”

It seems like ruby is treating $tring as a global variable. How do I avoid that? I tried to escape the value in my databag using some$string but then its not valid JSON.

How can I work around this?

Thanks  
Brad

---

<div class="post-metadata">

**Author:** ![joerg.herzinger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joerg.herzinger/32/1514_2.png) [@joerg.herzinger](https://discourse.chef.io/u/joerg.herzinger)\
**Post date:** [August 30, 2017, 10:57am UTC](https://discourse.chef.io/t/passing-databag-value-with-special-characters-to-powershell-block/11398/2 "2017-08-30T10:57:51Z")

</div>

A am not sure about powershell but usually double quotes mean that string interpolation is possible and single quotes mean its not. So in your case `write-host "'#{string}'"` would be quite different from `write-host '"#{string}"'`. Do you need the double quotes at all.
