Azure VM creation

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 : vmcreate · GitHub

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.

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.