Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Search instead for
Did you mean:
How To: Powershell on a Windows Agent
Usually the way I tell people to run powershell jobs to ensure output, and that they are running 64-bit versions of the cmd.exe and the powershell.exe is to drag those two exe files into the Agent/Bin directory. If you don't do this, then windows will force the 32-bit agent to only run 32-bit versions of powershell.exe EVEN IF you explicitly point to the 64-bit version in windows/system32 -- it'll still redirect to windows/SysWOW64 to use the 32-bit versions. This is a bug with the Windows operating system. Very often powershell scripts running in the wrong bit-version have errors in the script.
The way I do it is like this:
1.) Copy windows/system32/cmd.exe and windows/system32/powershell.exe into the Agent/Bin directory
This will ensure that the 64-bit versions are running by the agent. If you run it this way, the output will be printed to the output tab of the job. No need to write a batch script to call the powershell script.
A good way to verify the bit version the job is running inside is to open a task manager on the agent machine and look at the cmd.exe tasks. If the job becomes active and the new cmd.exe has nothing after it, it is 64-bit. If it has (32-bit) after, it is 32-bit.