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.ps1?
[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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark GalvinManaging Director / Principal ConsultantCommented:

Run this
Set-ExecutionPolicy Bypass

Open in new window

in PowerShell and that should stop.

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.
mystikal1000Author Commented:
We are already running in bypass mode.

powershell.exe -executionpolicy bypass -nologo -noprofile
Virus Depot: Cyber Crime Becomes Big Business

The rising threat of malware-as-a-service is not one to be overlooked. Malware-as-a-service is growing and easily purchased from a full-service cyber-criminal store in a “Virus Depot” fashion. View our webinar recording to learn how to best defend against these attacks!

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.
mystikal1000Author Commented:
This is what I have on the problematic machine.

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?
mystikal1000Author Commented:
How do you verify if the script is blocked?  Thanks!
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.  If the Unblock button is not there, then the file is not blocked.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.