mystikal1000
asked on
Powershell security warning, how to suppress?
We run reboot scripts on over a few hundred Windows servers, however there are some servers that do not reboot since it prompts for an acknowledgement.
The script is in powershell, the error is shown below.
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful this script can potentially harm your computer. Do you want to run \\server\share$\restart.ps 1?
[D] Do not run [R] Run Once [S] Suspent:
Any thoughts or ways to just suppress it, if you need the ps code, let me know.
The script is in powershell, the error is shown below.
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful this script can potentially harm your computer. Do you want to run \\server\share$\restart.ps
[D] Do not run [R] Run Once [S] Suspent:
Any thoughts or ways to just suppress it, if you need the ps code, let me know.
The reason you see that warning is because the execution policy is set to "Unrestricted", and you're trying to run a script that is detected as being downloaded from the internet. You can unblock the file by using the Unblock-File cmdlet, or right-click it > go to Properties > click the Unblock button near the bottom. Or you can also change the execution policy as suggested by Mark if desired.
ASKER
We are already running in bypass mode.
powershell.exe -executionpolicy bypass -nologo -noprofile
powershell.exe -executionpolicy bypass -nologo -noprofile
That may be true for most of your environment, but not where you're seeing that error. Also keep in mind that there are different scopes. Run Get-ExecutionPolicy -List on the problem machines.
ASKER
This is what I have on the problematic machine.
Get-ExecutionPolicy -list
Scope ExecutionPolicy
----- ---------------
MachinePolicy Unrestricted
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Unrestricted
Get-ExecutionPolicy -list
Scope ExecutionPolicy
----- ---------------
MachinePolicy Unrestricted
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Unrestricted
Compare that with what you have on a working machine. When set, the MachinePolicy will have the highest precedence (set through Group Policy), while LocalMachine will have the lowest.
If you want to post your code, that might be good. What's more important is how the script is being called on each machine, and whether any additional scripts are called from the first.
Have you checked to make sure the script files you're trying to run are unblocked?
If you want to post your code, that might be good. What's more important is how the script is being called on each machine, and whether any additional scripts are called from the first.
Have you checked to make sure the script files you're trying to run are unblocked?
ASKER
How do you verify if the script is blocked? Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Run this
Open in new window
in PowerShell and that should stop.Thanks
Mark