Reputation: 39058
I'm running the following command.
Set-ExecutionPolicy -ExecutionPolicy Bypass
It asks me if I'm sure and if I yes it, it sets the policy just as supposed to. I wonder, however, how I'm supposed to execute the command so that the computer doesn't ask me to confirm.
I've googled the issue and there's a flag -Confirm but using it produces an additional confirmation request. What would be the opposite of it, i.e. something like this (quacky typo intended)?
Set-ExecutionPolicy -ExecutionPolicy Bypass -JustDoWhatWeTellYouForDucksSake
Upvotes: 14
Views: 50889
Reputation: 27418
Or you can set the policy to unrestricted, but then whitelist whatever fileserver you're running a script from. There's probably a gpo way to do this too. The New-ItemProperty -Type parameter isn't easily found in the docs.
new-item -path 'hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\stackoverflow.com\server' -force > $null
new-itemproperty 'hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\stackoverflow.com\server' * -type DWORD -force > $null
Upvotes: 0
Reputation: 374
Here is one that is slightly better, as this one will work even if you do not have local administrator privileges. However, it only applies to the current Powershell session.
Set-ExecutionPolicy Bypass -scope Process -Force
Upvotes: 11
Reputation: 2718
As @Briantist pointed out in this case you want to use the -Force
switch to suppress the prompt. However for future reference in most cases the correct syntax to remove the confirmation prompt from most cmdlets is -Confirm:$False
Upvotes: 4