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.
If the path of the Agent is:
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.