#Start-ScheduledRunbook Param( [string]$Parameters, $RunbookName, $scheduleName ) #Initialize Variables $AutomationAccountName = Get-AutomationVariable -Name 'PAutomationAccountName' $ResourceGroupName = Get-AutomationVariable -Name 'ResourceGroupName' $PWRunonSvr = Get-AutomationVariable -Name 'RunOnSvr' #Write Output of Parameters Write-Output "Parameters:", $Parameters Write-Output "Runbook:", $RunbookName Write-Output "Schedule Name:", $scheduleName #region - Log into Azure Automation account from Hybrid worker $AzureCred = Get-AutomationPSCredential -Name 'AzureCreds' Login-AzureRMAccount -Credential $AzureCred #endregion #Convert Parameters into Hash Table $ParamHash = ConvertFrom-StringData -StringData $Parameters Write-Output "Running Runbook $RunbookName with the following parameters:" Write-Output $ParamHash #Start Runbook Start-AzureRmAutomationRunbook -AutomationAccountName $AutomationAccountName -Name $RunbookName -ResourceGroupName $ResourceGroupName -Parameters $ParamHash -ErrorAction Stop -RunOn $PWRunonSvr #Remove Schedule Remove-AzureRMAutomationSchedule -AutomationAccountName $AutomationAccountName -Name $scheduleName ResourceGroupName $ResourceGroupName -Force