Powershell script deployment failuire

anthony raimondi 21 Reputation points
2020-11-30T16:59:54.237+00:00

Hi Guys

I am trying to deploy a PowerShell script using SCCM package and I get the error code 0x1(1)

The log states Program failed with error code 1

If i deploy the script using SCCM Scripts it works perfectly

I am not sure why i get the error when deploying as a package

This is the command im using

"%Windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -Command .\VDA Upgrade.ps1

Any help will be great

Microsoft Security Intune Configuration Manager Other
0 comments No comments
{count} votes

Accepted answer
  1. Jason Sandys 31,406 Reputation points Microsoft Employee Moderator
    2020-11-30T19:18:19.863+00:00

    Error code 1 for PowerShell is typically due to the execution policy enforcing script signing. If your group policy enforces an execution policy, you cannot override this on the command line.

    Also, you don't want to use -command to execute a PowerShell script. -Command will just load the PowerShell script. You want to use -File to execute the script.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. anthony raimondi 21 Reputation points
    2020-11-30T19:28:57.51+00:00

    Thank you for the response Jason

    So it wont make a difference if I have set the PowerShell policy in SCCM Computer Agent client settings to bypass? GPO still would take precedent correct?


  2. anthony raimondi 21 Reputation points
    2020-11-30T20:37:15.73+00:00

    I think its working now. I changed to -File like you said and also took the sapce out on the PowerShell script name. I didn't have " " so maybe that why it failed?

    was ./VDA Upgrade.ps1 now its set to VDAUpgrade.ps1


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.