How to get rid of security warning in Batch/Powershell

24,665

Solution 1

Is your ps1 script reside in a network share ? You can skip all the security process by typing set-executionpolicy bypass in a admin powershell console

or you can invoke your script by powershell.exe -executionpolicy bypass -file \\servername\share\script.ps1

Solution 2

If the same error shows up, make sure you're setting the execution policy in the right place. On a 64 bit system there will be an execution policy for both 64 and 32 bit versions of Powershell. Normally, it loads the 64 bit version for the console, but uses the 32 bit version if called from a bat file. You need to launch the 32 bit version, running eleveated, and set the execution policy for it also.

Share:
24,665
Darktux
Author by

Darktux

Updated on August 16, 2020

Comments

  • Darktux
    Darktux almost 4 years

    enter image description hereI am trying to execute a powershell script via batch file and constantly getting the following warning;

    -> the execution policy is set to remote signed ; i also tested with Unrestricted, the same error shows up; how to get rid of this?