I'm using PowerShell scripts for some UI automation of a WPF application. Normally, the scripts are run as a group, based on the value of a global variable. It's a little inconvenient to set this variable manually for the times when I want to run just one script, so I'm looking for a way to modify them to check for this variable and set it if not found.
test-path variable:\foo
doesn't seem to work, since I still get the following error:
The variable '$global:foo' cannot be retrieved because it has not been set.