Using Powershell 5.1 runbook.
I'm trying to test sending an email from another runbook. The SendEmailToDba runbook runs successfully given the same parameters as I'm using in this second runbook. I cant figure out why it is complaining about the "ResourceGroupName" parameter. It is a required parameter of Start-AzureAutomationRunbook.
$params = @{ "destEmailAddress" = "[email protected]"; "fromEmailAddress" = "[email protected]"; "subject" = "test Email from Runbook"; "content" = "This is a test from another runbook" }
Write-Output( $params )
$job = Start-AzureAutomationRunbook `
-Name "SendEmailToDba" `
-Parameters $params `
-AutomationAccountName "myAccount" `
-ResourceGroupName "my-automation-resourcegroup"
Then I get the following error:
System.Management.Automation.ParameterBindingException: A parameter cannot be found that matches parameter name 'ResourceGroupName'.
at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection1 arguments) at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection1 arguments)
at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
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)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
The error
"ResourceGroupName"doesn't not recognized or wrongly given is coming because of the incorrect command.Start-AzureAutomationRunbookis not a validPowerShellcommand. You need to useStart-AzAutomationRunbook / Start-AzureRMAutomationRunbookcommands to start the automation runbooks.Note:
7.1 / 7.2to avoid few concerns.Az&Az.AutomationPowerShell module installed in theAzure Automation account -> Modulesto use theStart-AzAutomationRunbookcmdlet.I modified your script as below:
You can change the parameters and the relevant information as per the requirements and try the script.
Output: