When writing a powershell script in ISE I have something analogous to (which I execute with F5):
Function DoSomethingNow
{
"What am I doing?"
}
DoSomethingNow
The problem is if I rename or remove DoSomethingNow
it is still available in the session. This causes confusion in that my script will continue to work, whereas I would expect an error in the absence of the function.
I can only assume I need to clear the session after each round of debugging, however it would appear this is only possible by restarting ISE (therefore restarting the powershell session).
Therefore I ask:
- Is it possible to clear the session so that
DoSomethingNow
is no longer in scope? - What is the 'correct' way to debug and execute powershell scripts repeatedly?
- Perhaps I'm not using ISE the correct way?
I'd appreciate being pointed in the right direction.