Error: "The term 'reg' is not recognized as the name of a cmdlet"
This error can sometimes be found in the GetSoftware call to a Windows device. Typically, an error looks like this in your amagent log (amagent log obtained here: Location of Files Required by Automox):
2022/07/23 12:21:56 cmd_windows.go:183: runScript: Error in Wait exit status 90
status: 90
stdOut: Omitted
stdErr: At C:\ProgramData\amagent\execDir887431099\execcmd341723102.ps1:688 char:19
& reg load "HKEY_USERS\$userSID" "C:\Users\$userName\ …
~~~
System.Management.Automation.CommandNotFoundException: The term 'reg' 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.ActionCallInstruction2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action1 clause, Object dollarUnderbar, Object inputToProcess)
--- End of stack trace from previous location where exception was thrown ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
If you are encountering this error, the basic suggestion is to implement the correct Environment Variables to be able to handle this cmdlet for PowerShell. The solution to this error is to add the pathC:\Windows\System32\
to the Environment Variables:
- Right-click the My Computer icon then choose properties.
- Select the Advanced tab and then click Environment Variables.
- At the system variables panel, choose Path then click the Edit button.
- Add
C:\Windows\System32\
, the paths are separated by a semicolon.