Checking if a variable has a value is something I do very often in my scripts.
Most of the times, I do this by checking if the variable equals to $null.
However, there is a more performance friendly way to do this…
First, let’s create a few variables, which have the four most common types:
Next, let’s verify the types, just to show you that check it in the way I will show you, works for most (if not all) variable types:
Now to actually check if the variables have values:
…and to show you it correctly tells me if the parameter does exist, yet has no value in it: