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= ‘’, $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 : 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.