# How to check if string already exist in path env variable?

**URL:** <https://discourse.chef.io/t/how-to-check-if-string-already-exist-in-path-env-variable/11794>\
**Category:** Chef Infra (archive)\
**Created:** [October 21, 2017, 12:54pm UTC](https://discourse.chef.io/t/how-to-check-if-string-already-exist-in-path-env-variable/11794 "2017-10-21T12:54:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankur760](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Ankur760](https://discourse.chef.io/u/Ankur760)\
**Post date:** [October 21, 2017, 12:54pm UTC](https://discourse.chef.io/t/how-to-check-if-string-already-exist-in-path-env-variable/11794/1 "2017-10-21T12:54:44Z")

</div>

i want to put a not if to check path variable contain string or not ?

---

<div class="post-metadata">

**Author:** ![simark](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/simark/32/2099_2.png) [@simark](https://discourse.chef.io/u/simark)\
**Post date:** [October 22, 2017, 7:21am UTC](https://discourse.chef.io/t/how-to-check-if-string-already-exist-in-path-env-variable/11794/2 "2017-10-22T07:21:29Z")

</div>

I do not know which platform you want to run your code on, but you can specify the interpreter for your `not_if` and `only_if` guards with the `guard_interpreter` property  
[https://docs.chef.io/resource\_common.html#guard-interpreters](https://docs.chef.io/resource_common.html#guard-interpreters)

Then simply just right your corresponding code in the guards.

---

<div class="post-metadata">

**Author:** ![Ankur760](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Ankur760](https://discourse.chef.io/u/Ankur760)\
**Post date:** [October 22, 2017, 9:52am UTC](https://discourse.chef.io/t/how-to-check-if-string-already-exist-in-path-env-variable/11794/3 "2017-10-22T09:52:34Z")

</div>

I am using windows platform and can you show me how to put not\_if on env variable to be checked

---

<div class="post-metadata">

**Author:** ![simark](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/simark/32/2099_2.png) [@simark](https://discourse.chef.io/u/simark)\
**Post date:** [October 22, 2017, 11:11am UTC](https://discourse.chef.io/t/how-to-check-if-string-already-exist-in-path-env-variable/11794/4 "2017-10-22T11:11:02Z")

</div>

```ruby
some_resource 'name' do
  ...
  guard_interpreter :powershell_script
  not_if "$env:Path | Select-String 'some_value' "
end

```
