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, ie something like this (quacky typo intended)?
Set-ExecutionPolicy -ExecutionPolicy Bypass -JustDoWhatWeTellYouForDucksSake
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
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.