jsmorley wrote:I have not fully explored Powershell yet, as I'm leery that the default security setting for running .ps1 scripts is "disabled", but it does have a lot of promise.
Yes, it is a little confusing. The first time you run a script you may be prompted to run it as an admin and I think (??) you get prompted whether to allow scripts to run. I forget the exact process; once I answered the prompts, I don't get nagged anymore. Individual Powershell commands don't require this stuff, only scripts do.
Powershell is supposedly "secure by default". To set your script execution policy manually, open a Powershell prompt as an admin, then enter the following:
Set-ExecutionPolicy RemoteSigned
(options are: Restricted (the default), AllSigned, RemoteSigned, Unrestricted... I think RemoteSigned should be safe enough without being annoying.)
To test it, create a text file called "hello.ps1" that contains the following lines:
Write-Host "Hello, world"
Read-Host "Press Enter to continue"
Right-click the file in Explorer and select "Run with Powershell" from the context menu. If it runs without prompting, you are good to go. You can also open a command (cmd) shell and run the command
powershell .\hello.ps1 and you should get pretty much the same result (running a shell inside a shell feels a little weird, but...
). To run the script at a powershell prompt, the command is just
.\hello.ps1 (or even
.\hello).
Just to reiterate, all this is needed only for running scripts. Individual Powershell commands don't need any policy setting.
(Sorry for hijacking this thread, BTW.)