Using Azure automation, powershell runbook, I am trying to execute a script inside the VM.
$ServicePrincipalConnection = Get-AutomationConnection -Name 'AzureRunAsConnection'
Add-AzAccount -ServicePrincipal -TenantId $ServicePrincipalConnection.TenantId -ApplicationId $ServicePrincipalConnection.ApplicationId -CertificateThumbprint $ServicePrincipalConnection.CertificateThumbprint
$rgname ="rg-name"
$vmname ="vmName"
$ScriptToRun = "c:\temp\shutdown.ps1" #file exists in the VM
Invoke-AzVMRunCommand -ResourceGroupName $rgname -Name $vmname -CommandId 'RunPowerShellScript' -ScriptPath $ScriptToRun
But I get this error
"Could not find file 'c:\temp\shutdown.ps1'."
I found a similar problem mentioned here but the answer is confusing
"I found out that the file in question needs to exist on the local machine--not the remote machine."
We are only talking about one VM here so not sure what it means by local machine vs remote.