Hi All,
I am new to power-shell and cmldt.
I hv a power-shell script(.ps1) like "Invoke-xxDevopDt" and it registered as azure Runbooks with an azure Automation Account. This Runbook scheduled to do a another work on other date . Now ,I want to register this Runbook by using " Register-AzAutomationScheduledRunbook" at below ps-script as below
*param (
[Parameter(Mandatory = $false)]
[string]$resourceGroup='rsgrp_test',
[Parameter(Mandatory = $false)]
[string]$automationAccountName='Azureaucnt-test',
[Parameter(Mandatory = $false)]
[datetime]$startDateTime='01/05/2021 6:00:00 PM' ,
[Parameter(Mandatory = $false)]
[string]$vmResourceIds='/subscriptions/5454-7d8e-xxx-b628-yy3232/resourceGroups/TSTDEV/providers/Microsoft.Compute/virtualMachines/TSTDevVM',
[Parameter(Mandatory = $false)]
[String] $IncludedKBs='4588962',
[Parameter(Mandatory = $false)]
[datetime] $vmRestartDateTime='01/06/2021 4:00:00 PM',
[Parameter(Mandatory = $false)]
[String] $description = "Automated trigger from C# Program"
)
#do Login-AzAccount to login azure subcription
....
#setting data for
$AddMinutes = 7
# creating an scheduling and registering
$scheduleName = "testAPP_devopsSchedule_" + "$(Get-Date $vmRestartDateTime -UFormat %Y-%m-%d_%A_%H-%M)"
$devopsSchedule = New-AzAutomationSchedule -ResourceGroupName $resourceGroup `
-AutomationAccountName $automationAccountName `
-Name $scheduleName `
-StartTime ($vmRestartDateTime.AddMinutes($AddMinutes)) `
-Onetime -Verbose
#Createing a param for registering another PS-script as runBook with automation-acnt
$params = @{"serverList"=$vmResourceIds;"testMessage"="test";"description"="Invoking Automation from Automation Account"}
#register 'Invoke-xxDevopDt' is like a ps-script at runBook of automation-acnt
Register-AzAutomationScheduledRunbook –AutomationAccountName $automationAccountName `
–Name 'Invoke-xxDevopDt' –ScheduleName $devopsSchedule.Name –Parameters $params `
-ResourceGroupName $resourceGroup*
But, it gave an ERROR at "Register-AzAutomationScheduledRunbook : A positional parameter cannot be found that accepts argument 'Invoke-xxDevopDt'."
Any help
Thanks,