Beginning in version 220.127.116.11, which is currently available as beta version, you can now submit arguments to your scripts.
This can be very useful to test drive how your scripts accept and process arguments. And it’s simple.
Simply right-click the green “play” button to open a new context menu. It allows you to define arguments, and the arguments you enter are treated as if you had submitted them with the call to your script.
Once you defined arguments, run your script: click the “play” button, or press F5. In the interactive pane, you will notice how your arguments are appended to the command that runs the script.
To test drive this, your script could define a param() block, or you could use the variable $args to get access to the submitted arguments.
Disabling Automatic Dot Sourcing
You may not have noticed before, but ISE runs scripts differently than the PowerShell console.
In the PowerShell console, when you run a script, it runs in its own scope. So once the script completes, all variables defined in the script (and all functions as well) are cleaned up.
ISE in contrast always runs scripts dot-sourced. So a script shares the scope with the caller context. This eases debugging because all variables and all functions defined in a script stay alive.
ISESteroids makes sure you “see” the difference: when you run a script in ISE with ISESteroids loaded, in the interactive console you see a “dot” in front of the script call.
Starting in 18.104.22.168, you can now also right-click the green “play” button to change the default behavior, and make ISE behave like the PS console. Simply disable the automatic dot-sourcing to run scripts in their own scope.
Both adjustments – arguments and disabled auto-dotsourcing – apply to individual scripts. So you can change these settings on a script-to-script basis. They remain active until you turn them off again, or until you close the script.