Windows Agent - Powershell error: Specify a valid Windows PowerShell script file name, and then try again
search cancel

Windows Agent - Powershell error: Specify a valid Windows PowerShell script file name, and then try again

book

Article ID: 428037

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

Windows Agents to the version 24.4.3 (previously on 21.0.9) and now we receive the following error, when starting an powershell command in the custom intepreter context. 

The error looks like this:

 

Processing -File 'D:\Program' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.

Windows PowerShellCopyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

 

Environment

Automation Engine V 24.x
Windows Agent V 24.x

Resolution

A "Space" between the folder structure is considered as a new parameter.

Which is the reason we see the Windows V 24 agent is failing to execute a sample powershell job with below error indicating about the space in the agent installation folder structure.

Processing -File 'D:\Program' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.

The reason why the same powershell job works with the V 21 agent is because of the architectural difference. As you know the V 21 agents are C based agents and V 24 agents are JAVA based agents.

The C based agent type ignores the space and results you the desired output however this is not a possible in JAVA based agents as the space in JAVA is considered as a new parameter.

You can follow below workaround when not willing to modify the agent directory path (folder structure) 

Workaround:

  1. Got to V 24 agent ini file.
  2. Modify the below line in quotes

    Your current configuration:

    ecpexe=powershell.exe -NonInteractive -ExecutionPolicy bypass -NoLogo -file

        Modify to below:

        ecpexe=powershell.exe -NonInteractive -ExecutionPolicy bypass -NoLogo -file "

      3. Restart the agent
       4. Test the powershell job, it executes successfully.