locked
Error: "File cannot be loaded because the execution of scripts is disabled on this system" RRS feed

  • Question

  • Hello,

    I'm executing powershell scripts from command prompt. I've changed my execution policy to Unrestricted. Also, Get-ExecutionPolicy is showing 'Unrestricted'. When i execute following error

    "File cannot be loaded because the execution of scripts is disabled on this system"

    Reason ?


    Sohaib Khan
    Wednesday, August 10, 2011 12:23 PM

Answers

All replies

  • Is it a 64 bit machine? If so, open the x86 instance of PowerShell and check (set) the execution policy.
    Shay Levy [MVP]
    PowerShay.com
    PowerShell Toolbar
    • Marked as answer by Sohaib Khan Wednesday, August 10, 2011 12:52 PM
    Wednesday, August 10, 2011 12:33 PM
  • Yes, it's a x64 machine and i'm using SharePoint 2010 Management Shell.

    Where can i find x86 instance ?


    Sohaib Khan
    • Proposed as answer by testanicet Wednesday, June 5, 2013 11:54 AM
    • Unproposed as answer by testanicet Wednesday, June 5, 2013 11:54 AM
    Wednesday, August 10, 2011 12:39 PM
  • Yes, it's a x64 machine and i'm using SharePoint 2010 Management Shell.

    Where can i find x86 instance ?


    Sohaib Khan
    %windir%\SysWOW64\WindowsPowerShell\v1.0
    • Proposed as answer by Riyas Hussain Wednesday, June 5, 2013 8:30 AM
    Wednesday, August 10, 2011 12:43 PM
  • Please try this

    Set-ExecutionPolicy Unrestricted

    Wednesday, February 1, 2012 11:27 PM
  • Try with Force switch

    Set-ExecutionPolicy Unrestricted -Force


    Regards Ram
    • Proposed as answer by tarah4 Thursday, April 3, 2014 4:39 PM
    Thursday, February 2, 2012 9:27 AM
  • If I use -Force I get...

    A parameter cannot be found that matches the parameter name 'Force'

    Monday, April 30, 2012 11:07 AM
  • Had the same issue, and this has fixed it for me!

    Seems a bit odd that the system would have different Execution Policies for 32 and 64-bit though doesn't it?

    Thanks for the help!

    • Proposed as answer by Roel Janssens Tuesday, April 15, 2014 7:55 AM
    Friday, June 15, 2012 9:52 AM
  • Running powershell as Administrator and executing "set-ExecutionPolicy Unrestricted" worked for me.
    Thursday, February 20, 2014 6:46 PM
  • Does this option not leave the system unsecure by forever changing the powershell script running option? Where can you programmatically set it to only allow certain scripts to run. Else you just made this computer a beautiful honey jar for a hacker.
    Wednesday, May 7, 2014 9:10 PM
  • Does this option not leave the system unsecure by forever changing the powershell script running option? Where can you programmatically set it to only allow certain scripts to run. Else you just made this computer a beautiful honey jar for a hacker.

    If you only want certain scripts to run, you'll need to sign them and leave the policy as Restricted.

    I use RemoteSigned personally. You may also want to research Bypass.


    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Wednesday, May 7, 2014 10:24 PM
  • Running powershell as Administrator and executing "set-ExecutionPolicy Unrestricted" worked for me.

    It worked for me too, thanks!
    Thursday, May 15, 2014 3:31 PM
  • Changing the powershell execution policy allowed me to run scripts on my windows Azure Server.

    This is heaps better now I can run my own scripts.


    Regards Jake Gardner If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing! Sorry if my grammar is incorrect as I am probably on writing to you from my phone.

    Monday, May 26, 2014 12:08 PM
  • Worked ... thanks...
    Tuesday, July 15, 2014 1:09 PM
  • This certainly works, thank you.
    Monday, December 1, 2014 11:40 AM
  • There is a solution that I think is better than changing the policy for scripts in general, and that is to add the "-ExecutionPolicy ByPass" to the command you give.  So I had this problem with a shortcut to a ps1 file where the target was:

    %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe  -File "C:\ReBirth RB-338\Rebirth.ps1" 

    By changing this to:%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -File "C:\ReBirth RB-338\Rebirth.ps1"

    The problem was solved without changing any general security settings.  You can, I assume, add the same switch at the command line.  Personally I think this is a better solution from a security point of view - though since hackers can use the same switch, how secure is another issue

    Hope this helps  MIchael

    Saturday, November 18, 2017 6:09 PM
  • If i use this powershell command it hides the entire mailbox
    Set-Mailbox -Identity email@domain.com -HiddenFromAddressListsEnabled $true

    Does anyone how can I hide a secondary email address from the GAL but not the entire identity?

    Monday, November 27, 2017 1:56 AM
  • Ever get a response to this? I am guessing it is a new issue.. but I am looking to solve this problem myself.. for "secondary/alias email address"
    Wednesday, January 2, 2019 5:30 PM