Hmmm. Today I was looking up for how to test the existence of a variable a quick google search turned up a solution on stackoverflow.
Here’s the gist of is, you can use the ‘variable PsProvider’ to test the existence of a variable.
Read the entire thread over here.
Mentioned here only for my convenience and archival purposes. The entire credit goes to the post on stackoverflow.