0

Is there a workaround for execution policies?

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\stock.ps1
.\stock.ps1 : File C:\Users\thufir\Desktop\stock.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
+ .\stock.ps1
+ ~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\thufir\Desktop>

I am just looking to find stock quotes with a script. Yes, you can sort of/kind of run a script with copy/paste, but...isn't there anything nicer?

Policy is as:

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined


PS C:\Users\thufir\Desktop>

(Not my machine.)

I am looking for the inverse to this question.

1
  • 3
    Start powershell.exe using the -ExecutionPolicy RemoteSigned command-line arguments. Commented Feb 15, 2018 at 19:02

1 Answer 1

1

To build off of Bill_Stewart's comment, create a shortcut with the following target and it will allow you to run a PowerShell script:

 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file "\\Server\Path\to\script\script.ps1"

If you want to run this command on a remote machine, you can can always do something like this after creating the above shortcut and storing it somewhere the remote machine can access on the network.

Invoke-Command -computername Computer1 -Scriptblock { Start-process "\\Server\Path\to\shortcut\shortcut.lnk" }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.