0

I'm looking for a way to run a script that creates a simple windows vm with rdp port and installs a software on it in order give our clients a simple sand boxed server for testing purposes. Is there a simple way to do that as I've been struggling for a while now.

1 Answer 1

1

You should use custom script extension for Azure VM. Depending on how you create vms you can use powershell\cli\arm templates\rest api\sdk to use that extension.

sample powershell:

$ProtectedSettings = @{"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File \\filesvr\build\serverUpdate1.ps1"};

Set-AzureRmVMExtension -ResourceGroupName myRG 
    -Location myLocation ` 
    -VMName myVM ` 
    -Name "serverUpdate" 
    -Publisher "Microsoft.Compute" `
    -ExtensionType "CustomScriptExtension" ` 
    -TypeHandlerVersion "1.9" `
    -ProtectedSettings $ProtectedSettings

ARM Template sample: https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-custom-script-windows
AZ cli sample: https://blogs.technet.microsoft.com/paulomarques/2017/02/13/executing-custom-script-extension-using-azure-cli-2-0-on-an-azure-linux-virtual-machine/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.