Azure Automation - The term 'Out-String' is not recognized as a name of a cmdlet, function, script file, or executable program

Peter van Rossum 30 Reputation points
2024-01-25T08:33:36.46+00:00

Hi,
This morning one of my runbooks got an error.
What has happened? And can it be fixed?

Exception : System.Management.Automation.CommandNotFoundException: The term 'Out-String' is not recognized as a name of a cmdlet, function, script file, or executable 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.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) at Automation.Sandbox.Core.JobExecutor.PowerShell.TextStreamConverter.ConvertObjectToText(Object streamRecord) in C:\__w\1\s\src\Automation.Sandbox.Core\JobExecutor\PowerShellStreamProcessing\T extStreamConverter.cs:line 64
at Automation.Sandbox.Core.JobExecutor.PowerShell.PsStreamConverter.Convert[T](PSDataCollection`1 dataCollection, StreamType streamType) in C:\__w\1\s\src\Automation.Sandbox.Core\JobExecutor\Pow erShellStreamProcessing\PsStreamConverter.cs:line 39
at Automation.Sandbox.Core.JobExecutor.PowerShell.PowershellJobExecutor.HandleStreamDataAdded [T](StreamType streamType, JobProperties jobProperties, PSDataCollection`1 dataCollection, Boolean shouldSaveStream) in C:\__w\1\s\src\Automation.Sandbox.Core\JobExecutor\PowershellJobExecutor.cs:line 203 at Automation.Sandbox.Core.JobExecutor.PowerShell.PowershellJobExecutor.<>c__DisplayClass20_0 .<AttachJobStreamDataEventHandlers>b__2(Object sender, DataAddedEventArgs e) in C:\__w\1\s\src\Automation.Sandbox.Core\JobExecutor\PowershellJobExecutor.cs:line 183
at System.Management.Automation.PSDataCollection`1.RaiseEvents(Guid psInstanceId, Int32 index)
at System.Management.Automation.PSDataCollection`1.InternalAddRange(Guid psInstanceId, ICollection collection) at System.Management.Automation.Internal.PSDataCollectionStream`1.Write(Object obj, Boolean enumerateCollection) at System.Management.Automation.Internal.Pipe.AddToPipe(Object obj)
at System.Management.Automation.ExceptionHandlingOps.ReportErrorRecord(IScriptExtent extent, RuntimeException rte, ExecutionContext context)
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at verwerk-folder(Closure , FunctionContext )
at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) --- End of stack trace from previous location ---
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 verwerk-folder(Closure , FunctionContext ) TargetObject : Out-String CategoryInfo : ObjectNotFound: (Out-String:String) [], CommandNotFoundException FullyQualifiedErrorId : CommandNotFoundException ErrorDetails : InvocationInfo : System.Management.Automation.InvocationInfo ScriptStackTrace :
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-folder, <No file>: line 143
at verwerk-library, <No file>: line 87
at <ScriptBlock>, <No file>: line 584 PipelineIterationInfo : {} PSMessageDetails :

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,305 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,421 Reputation points
    2024-01-25T14:41:44.89+00:00

    Hi @Peter van Rossum ,

    I have tried to reproduce the issue, but I am able to successfully use the 'Out-String' cmdlet in my runbooks of different runtime versions. As per the error, 'Out-String' cmdlet is not recognized which means that either module containing the cmdlet is missing from the account, or there's a name conflict with a runbook name, or the cmdlet also exists in another module and Automation can't resolve the name.

    To fix the issue, you can try the following solutions:

    • Ensure that the cmdlet exists in your Automation account by looking for Microsoft.PowerShell.Utility module in the modules tile of your Automation account and that there are no conflicts. Another way to verify if the cmdlet is present, open a runbook in edit mode and search for the cmdlet you want to find in the library, or run Get-Command <CommandName>. After you've validated that the cmdlet is available to the account, and that there are no name conflicts with other cmdlets or runbooks, add the cmdlet to the canvas. Make sure that you're using a valid parameter set in your runbook.
    • If you do have a name conflict and the cmdlet is available in two different modules, resolve the issue by using the fully qualified name for the cmdlet. For example, you can use ModuleName\CmdletName.
    • If you're executing the runbook on-premises in a hybrid worker group, ensure that the module and cmdlet are installed on the machine that hosts the hybrid worker.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.