I know that there is that little -noexit
switch for PowerShell.
Is there anyway of staying in the shell without using that switch?
In other words, I
The while loop at the end of this trivial script prompts me for a command and executes it. It runs with the environment of the script, so it is possible to check the values of variables. Entering "exit" terminates the loop when it is executed.
# Do something.
cd D:\temp
$current_directory = $(pwd)
dir
write-host # Just add a little space after the dir
# Stay in the shell and execute commands.
while ($TRUE) {
$cmd = Read-Host "PS $(pwd)"
if ($cmd[0] -eq '"') { iex "& $cmd" }
else { iex $cmd }
}
I'm sure that others will be able to share some refinements, but this is a start. Regards.