0
votes

Since many days I am trying to sysprep an azure virtual machine.

Following is the command that I am using to connect to the VM from local and executing the Upload-GoldImage.ps1 script

Invoke-Command -ConnectionUri $uri -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Credential $credential -ScriptBlock {C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -file "c:\program files\WindowsPowershell\Upload-GoldImage.ps1" -validateCurrentOS}

remote machine gets connected successfully. All the commands in the ps1 file are executed successfully but only the sysprep command isn't executing.

The ps1 mentioned above contains one command to sysprep the machine - Start-Process -FilePath C:\Windows\System32\Sysprep\sysprep.exe -ArgumentList '/generalize /oobe /shutdown /quiet'

Write-Host("After sysprep")

When this gets executed on my local powershell prompt - "After sysprep" is getting printed. I am getting no error in the sysprep command. Still the machine is not getting sysprepped.

Please if anyone could help me out

Thanks.

1

1 Answers

0
votes

Finally I was able to sysprep the machine from my local powershell.

Previously my script used Start-Process command.

But then, http://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx#Diagnostics_Process_Start - this link helped me out, where I tried various several ways mentioned in the link.