This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

Automate Creating Lab Virtual Machines in Azure with PowerShell

As you may or may not know, I recently decommissioned my old Dell PowerEdge 1950 server that I used for a few Lab virtual machines. While experimenting with PowerShell on these Virtual Machines, I have found myself in the situation where it would be easier to delete the Virtual Machines and re-create them instead of troubleshooting something I fouled up in the Registry. After the 2nd time rebuilding the lab VMs using the Azure website, I decided to script the process.

The script below will take input from a CSV file and create a virtual machine in your Azure subscription for each row in the CSV file. My example creates 2 virtual machines but you can obviously add as many as you need.

For a production environment in Azure, I would suggest Snapshotting the Virtual Machines. There is a good write-up of the process here: http://www.coreazure.com/snapshot-vms-in-azure-resource-manager/. In my case, for a Lab, snapshots use more storage which costs more $$.



1 Comment

  1. Diego S | | Reply

    Hola no me funciona, me arroja el siguiente error :

    New-AzureLab : El término ‘New-AzureLab’ no se reconoce como nombre de un cmdlet, función, archivo de script o
    programa ejecutable. Compruebe si escribió correctamente el nombre o, si incluyó una ruta de acceso, compruebe que
    dicha ruta es correcta e inténtelo de nuevo.
    En línea: 1 Carácter: 1
    + New-AzureLab -csvpath c:\scripts\VMs.csv
    + ~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (New-AzureLab:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Suggestion [3,General]: No se encontró el comando New-AzureLab, pero existe en la ubicación actual. Windows PowerShell no carga comandos de la ubicación actual de forma predeterminada. Si confía en este comando, escriba “.\New-AzureLab”. Vea “get-help about_Command_Precedence” para obtener información más detallada.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.