0

I have written a powershell script, but when i try to run it, i get an error saying .ps1 file cannot be loaded and It is not digitally signed.

Powershell.exe -ExecutionPolicy Unrestricted -File script.ps1

Please help me out to solve this issue.

ananth joshi
  • 747
  • 3
  • 9
  • 11

2 Answers2

0

try using:

powershell.exe -ExecutionPolicy Bypass -File script.ps1
CB.
  • 58,865
  • 9
  • 159
  • 159
  • I tried Bypass, it is still giving me the same error – ananth joshi Apr 16 '14 at 10:00
  • Could you post (copy and paste) exactly the error please? – CB. Apr 16 '14 at 10:09
  • File C:\Users\abc\Powershell\Rep.p s1 cannot be loaded. The file C:\Users\abc\Powershell\Rep.ps1 is not digitally signed. The script will not execut e on the system. Please see "get-help about_signing" for more details.. + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE xception + FullyQualifiedErrorId : RuntimeException – ananth joshi Apr 16 '14 at 10:18
  • um.. maybe some group policy affect your computer? Can you try this script on another computer? – CB. Apr 16 '14 at 10:23
  • do you know how to change the group policy? – ananth joshi Apr 16 '14 at 10:27
  • @ananthjoshi are you in a domain or stand alone computer? – CB. Apr 16 '14 at 10:29
0

Unrestricted will prompt you with a warning for downloaded files. Try using the executionpolicy Bypass. As an alternative, you could go into the properties of the file and unblock the file.

-- Unrestricted: Loads all configuration files and runs all scripts. *If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.

-- Bypass: Nothing is blocked and there are no warnings or prompts.

Source: Set-ExecutionPolicy

Frode F.
  • 52,376
  • 9
  • 98
  • 114