You can doit by using the Null-coalescing assignment operator ??=
$ExistingVar = 'set by script' $MyPath ??= $env:PWD $MyVar ??= 'default value' $ExistingVar ??= 'Cannot set this string to not null vars' echo $MyPath echo $MyVar echo $ExistingVar