Azure VM creation

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of mohit goyal mohit goyal 1 month, 2 weeks ago.

  • Author
    Posts
  • #55495
    Profile photo of Soma sympli
    Soma sympli
    Participant

    I have created below script which will spin azurerm vm from an existing vhd. script works fine

    however I will have to modify the variables ( $vmname='TESTVM', $bootstorageaccount='TESTSTORAGE', $vhduri= 'https://TESTSTORAGE.blob.core.windows.net/TESTVM.vhd', $OSDISKNAME = "TESTVMOSDISK" & $size='Standard_D3_v2' $ip='10.0.1.9')
    everytime I want to create a new VM

    is there a way to make the script better, or to automate the variables to take from an notepad or excel or ask on commandline to enter those details?
    Script :

  • #55723
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Sure. You should parameterize your script, by adding a Param() block. You might also consider "Learn PowerShell Toolmaking in a Month of Lunches," since it's pretty much all about taking a script like this and turning into a more formal, reusable tool.

  • #55771
    Profile photo of mohit goyal
    mohit goyal
    Participant

    Don is right. Parameterized script is the way to go. You can also use Read-Host to ask values at run time and/or import values from excel/csv/xml format files. Lots of options to choose from.

You must be logged in to reply to this topic.