Sometimes you have the need to add additional disks to VM’s in Azure.. and if you happen to manage a big farm of servers and all servers need to have additional disks, you find yourself in the portal a lot.. or in Powershell hacking your way through variables and collections..
This script will help you adding one or multiple disks to a single VM, all VM’s in a ResourceGroup or all VM’s in a ResourceGroup starting with a particular nameThe powershell script can be found here -> diskadd-toVM <- and has the following command options:
The script has the following parameters:
-ResourceGroup [mandatory]
Provide the name of the resource group containing your VM(s)
-SizeinGB[Mandatory]
Size of disks to add
-Cache[Mandatory]
Defines the cache for the disk [none/readonly/readwrite]
-TargetVM [optional]
Specify a single VM to add disks to [if not specified and VMPrefix is not specified script will run against all VM’s in a ResGroup]
-VMPrefix[optional]
Used to add disks to all VM’s starting with this name (for example “ClusterNode”) [if not specified and TargetVM is not specified script will run against all VM’s in a ResGroup]
-MaxDisks[optional] [default = $false]
If specified, will add multiple disks to the max entered here (eg all servers will have <12 disks after running this with 12)
-MaxDisks[optional] [default = $false]
$false : will not create a log file
$true : creates a logfile in form of: AzureCleanLog-19-4-17-10.48.27.log in the current directory
So your initial commands are: