Powershell build step calling a custom mudule fails with CommandNotFoundException

I have a number of custom powershell modules which i have installed on all of the TC buld agants. I have modified the $env:PSModulePath at the machine level on all of the build agents to include all of these modules for all users. I can invoke all of the individual commands on the build agents. I also have a powershell build step whose job it is to invoke one of these commands. However, each time the build step executes I recieve an exception of CommandNot found. Can anyone shed any light on this?

I should also mention that I have wrapped my command in a try catch to display the error output in the build log. That is how I know what the exception is (see below). Also if I get the build step to invoke Get-Module -ListAvailable my custom modules are not present.

System.Management.Automation.CommandNotFoundException:
The term 'New-Cmdlet' 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.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
1 comment
Comment actions Permalink

I have restarted the machines that act as build servers. My modules are now visable to the powershell environment that the build agents envoke.

0

Please sign in to leave a comment.