Have a similar question answered in https://video2.skills-academy.com/answers/questions/865850/building-vm-template-or-golden-image-with-azure-ar.html
Have the Arc agent installed in the image, however need to run the connect script at system boot as each VM created from the template starts for the first time, not when a user logs in.
Created a scheduled task to run at boot, however receiving an error, this is output from the Powershell script invoked by the scheduled task.
time="2022-07-26T09:53:47+10:00" level=info msg="Exit Code: AZCM0070: Unable To Obtain Local Config"
time="2022-07-26T09:53:47+10:00" level=fatal msg="open \\.\PIPE\himds: The system cannot find the file specified."
Script is
Run connect command
& "$env:ProgramW6432\AzureConnectedMachineAgent\azcmagent.exe" connect --service-principal-id "$servicePrincipalClientId" --service-principal-secret "$servicePrincipalSecret" --resource-group "$resource_group" --tenant-id "$tenant_id" --location "$location" --subscription-id "$sub" --cloud "AzureCloud" --correlation-id "$corrID" | out-file C:\output.txt -Append
Have tried running the scheduled task as SYSTEM and also the local administrator, but the same issue.
If I manually run the task, it completes correctly and the VM is registered.
Any ideas?