Executing PowerShell script on Windows results in path error when path contains a space

Document ID : KB000084935
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
Error Message :
D:\Program : The term 'D:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

When attempting to run a PowerShell command against a Windows Agent which is installed in a path containing blank spaces (e.g. C:\Program Files), the above error message will appear in the report of the Windows Job.  Note, the Windows Job will not necessarily fail due to the error, but can.

Investigation

If the path of the Agent is:

D:\Program Files\uc4\Agent\ara-agent\bin\

When a PowerShell script is executed from a Windows Agent the following error will appear in the report of the Windows Job:

D:\Program : The term 'D:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The PowerShell script is executed from the \bin directory of the Agent, and it is not able to resolve the path because of the space within the directory name “Program Files”, causing the script to fail.

Environment:
OS: Windows
OS Version: N/A
Cause:
Cause type:
Other
Root Cause: PowerShell scripts executed on a Windows Agent are unable to resolve a path with a space in it from the Windows side.
Note! for this reason it is strongly suggested not to install the agents into the default windows provided directory (C:\Program Files)
Resolution:
Use an Agent which is installed in a path that does not contain spaces such as C:\Automic\Agents\WIN01\bin.

In addition, this will prevent other issues that might be encountered when there is a space in the Agent's path.


Fix Status: No Fix

Fix Version(s):
N/A
Additional Information:
Workaround :
N/A