azure cli command to run the sysprep

Vedanth Pulipati 241 Reputation points
2022-02-01T17:22:18.18+00:00

i am trying to run the sysprep before converting it into an image

i have used the following command for the sysprep

az vm run-command invoke --command-id RunPowerShellScript -g $resourceGroupName -n $serverName --scripts .\resources\win-vm\sysprep.ps1

in the file sysprep.ps1 consists the below command

C:\WINDOWS\system32\sysprep\sysprep.exe /generalize /shutdown /oobe

the below is the error i am facing
170284-image.png

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,065 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. shiva patpi 13,131 Reputation points Microsoft Employee
    2022-02-01T18:31:06.053+00:00

    Hello @Vedanth Pulipati ,
    Can you try out Invoke-AzVMRunCommand ?
    Sample example:

    Invoke-AzVMRunCommand -ResourceGroupName syspredemo -VMName sysprepdemo -CommandId "RunPowerShellScript" -ScriptPath "C:\aks\date.ps1"

    170311-image.png

    Let me know if that helps !