error on starting powershell -executionpolicy

Welcome Forums General PowerShell Q&A error on starting powershell -executionpolicy

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
4 years, 6 months ago.

  • Author
    Posts
  • #14130

    Participant
    Points: 0
    Rank: Member

    Hi, I am getting the following error on one of the servers I tested (it worked fine on other servers), what could be run?

    Thanks!

    Yung

    C:\>powershell -ExecutionPolicy ByPass -File C:\Users\chengyu\Documents\UD_stat
    us.ps1
    Missing expression after unary operator '-'.
    At line:1 char:2
    + -E < <<< xecutionPolicy ByPass -File C:\Users\chengyu\Documents\UD_status.ps1 C:\>

  • #14131

    Member
    Points: 0
    Rank: Member

    Does that server have PowerShell v1 installed, by chance? The syntax you posted should be working on PowerShell 2.0 or later, but I'm not sure about 1.0 (which I never used.)

  • #14135

    Participant
    Points: 0
    Rank: Member

    Yes, that server is v1. So this command is not working for v1? The problem is that some of the servers has executionpolicy set to "restricted" (i will run the script on many servers and I don't want to change the policy manually on each one, nor do i want to change the registry to relax the policy). I thought -ExecutionPolicy ByPass would be the best choice, but then this problem occurs.

    Thanks for responding.

    Yung

  • #14145

    Participant
    Points: 0
    Rank: Member

    Unless you have a really compelling reason to stay at v1, you really should upgrade PowerShell. You don't get all the remoting goodness until at least v2.

  • #14147

    Participant
    Points: 0
    Rank: Member

    If I remember correctly ExecutionPolicy wasn't available as a start-up parameter on PowerShell v1

  • #14148

    Participant
    Points: 0
    Rank: Member

    OK, looks like I have to rewrite my program using VB.... If I had control, i would have forced them to upgrade powershell version.

    Thanks all for your help!

The topic ‘error on starting powershell -executionpolicy’ is closed to new replies.