Solved

Unable to run a power shell scripts

Posted on 2013-01-18
4
948 Views
Last Modified: 2013-02-07
Hi,

I am running Windows 8. In Windows Power shell ISE , I had set the Execution policy to RemoteSigned. but if I run the power shell script,i am getting the following message.

Hello : File C:\Power_Shell-Scripts\Hello.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Hello
+ ~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
0
Comment
Question by:sivakugan
4 Comments
 
LVL 18

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 100 total points
ID: 38795502
Try
set-executionpolicy unrestricted
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 100 total points
ID: 38795505
Is the script remote-signed  ?

        RemoteSigned
            - Scripts can run.

            - Requires a digital signature from a trusted
              publisher on scripts
and configuration files that
              are downloaded from the Internet (including
              e-mail and instant messaging programs).

What you need for your script might be to set-execution policy bypass as a part of your script
0
 
LVL 10

Accepted Solution

by:
Prashant Girennavar earned 200 total points
ID: 38795728
You need to see what is the excution policy set.

Open the powershell console and type

Get-ExecutionPolicy

If it comes as Restricted,

Make it as REMOTESIGNED.

To do that,

Run below command in Powershell console( Open the console with Administrator privilages)

Set-Executionpolicy RemoteSigned.

Say "Yes" for confirmation.

Hope this helps

Thanks,

_Prashant_
0
 
LVL 17

Assisted Solution

by:Learnctx
Learnctx earned 100 total points
ID: 38798245
Also remember that Powershell 32-bit and 64-bit have separate execution policies. So set them in both environments (Powershell and Powershell (x86)). You can also set the execution policy when launching Powershell:

powershell.exe -executionpolicy unrestricted
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bash Script to Analyze Oracle Schemas 11 80
React or Angular? 6 51
hiding bulk external contacts 2 32
Debugging a shell script 3 12
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now