Azure VM creation

Welcome Forums General PowerShell Q&A Azure VM creation

This topic contains 2 replies, has 3 voices, and was last updated by

2 years, 2 months ago.

  • Author
  • #55495

    Points: 76
    Rank: Member

    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= '', $OSDISKNAME = "TESTVMOSDISK" & $size='Standard_D3_v2' $ip='')
    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

    Points: 1,759
    Helping HandTeam Member
    Rank: Community Hero

    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

    Points: 0
    Rank: Member

    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.

The topic ‘Azure VM creation’ is closed to new replies.