Difference between Clear-Variable and setting variable to NULL
问题 I often use variables which are declared in the script scope to avoid problems with functions and their scopes. I am declaring these variables like this: New-Variable -Name test -Option AllScope -Value $null ... or sometimes I switch existing variables like this to use them comprehensively: $script:test = $test When I want to clear them I either use this: Clear-Variable test -Scope Script ... or I simply use this: $test = $null Is there a difference? What should I prefer and why? 回答1: From