I have a script with a standard string param in it. In the script, I want to detect if this string is $null. I've included a script snippet. Rather than using 2 variables, is it possible to set a condition only on the parameter? Something like setting a type of [param] like if ([param]$x) ?
param($x) $somearray = 'product1′,'product2′ foreach ($element in $somearray) { ## I only want to test against the $x set by the param ## I don't want this if $x was set lower in the script if (!$x) { do something } …… ……. $x = 'something' }