Say I have the following powershell script:
$hello = "Hello World"
Write-Output $hello
When I run it I get
Hello World
Then I decide that I want my variable to be named $helloWorld
:
$helloWorld = "Hello World"
Write-Output $hello
When I run that I get
Hello World
What I want is for that to fail because I have not defined $hello
(or at least write out an empty string).
I have seen some examples that try to record off all the variables before running and calling Remove-Variable on all the new ones after. This seems like a lot of work.
I thought I would ask if today's powershell has a better solution. Basically I am looking for a command that will reset the terminal's variable memory back to the initial startup state.