I can run the below command without any problem:
Invoke-Command -ScriptBlock {
Param($rgName,$VMname)
Get-AzureRmVM -Name $VMname -ResourceGroupName $rgName
} -ArgumentList $rgname,$vmname
But what I really need is to be able to run the command as a job, so I tried the below:
Invoke-Command -ScriptBlock {
Param($rgName,$VMname)
Get-AzureRmVM -Name $VMname -ResourceGroupName $rgName
} -ArgumentList $rgname,$vmname -AsJob
And I'm receiving the following error:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters. At line:1 char:1 + Invoke-Command -ScriptBlock { param($rgName,$VMname) Get-AzureRmVM -N ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
I've also tried to run the command using Start-Job
instead but I'm also receiving errors.