Scripts Thread, Change Powershell ExecutionPolicy to RemoteSigned via BATCH in Coding and Web Development; So I'm pinning together a batch file that automatically installes Windows Management Framework 3.0 and the domain Powershell certificates for ...
Change Powershell ExecutionPolicy to RemoteSigned via BATCH
So I'm pinning together a batch file that automatically installes Windows Management Framework 3.0 and the domain Powershell certificates for scripts signed by me, but by default ExecutionPolicy is set to Restricted and it needs to be RemoteSigned.. So far the best method I've got is
This launches a Powershell CLI and I just paste the command in, press Enter and done! But since there's ways to pass commands to Powershell via batch (using -command) I figured I'd try and automate this bit..
This successfully launches an administrative Powershell window (after UAC prompt) and 'Set-ExecutionPolicy RemoteSigned -Force' does appear in the window. It then waits for further commands with 'PS C:\Windows\system32> _'.. Get-ExecutionPolicy tells me it's Bypass still (which I'd expect for that instance) but if I check with a different powershell window it's still set as Unrestricted (testing on my machine)
I figure it's probably a security thing, but is there a way of passing it automatically?
Either of the commands below will set the execution policy (as long as they are run elevated).
The batch itself can't be run as an admin else the Framework Management installer fails (I have no idea why..) which is why it first launches a regular powershell window that then launches an administrative powershell window.