If you’re working with Aria Automation (formerly vRealize Automation) and want to give users the ability to add extra disks to a Windows VM — and define their drive letter and volume label — you’re in the right place. This guide shows you how to build a flexible and reusable cloud template (blueprint) that handles additional disks dynamically.
We’ll cover:
- YAML blueprint inputs for user-defined disks
- Cloud-init with PowerShell to configure drives
- Handling drive letter and label assignment dynamically
- Ensuring all disks are initialized and formatted properly
Step 1: Define Inputs for Additional Disks
In your Aria Automation blueprint YAML, start by defining an input array that allows users to specify up to 4 additional disks, including their desired SCSI unit number, disk size, drive letter, and volume label.
inputs:
additionalDisks:
type: array
title: Additional Disks
description: |
Add extra Windows disks with specified drive letter and label. Max: 4
minItems: 0
maxItems: 4
items:
type: object
properties:
diskController:
type: string
title: SCSI Controller
enum:
- SCSI_Controller_1
- SCSI_Controller_2
- SCSI_Controller_3
- SCSI_Controller_4
default: SCSI_Controller_1
diskUnit:
type: integer
title: SCSI Unit Number
minimum: 1
maximum: 4
diskSize:
type: number
title: Size (GB)
minimum: 1
maximum: 500
driveLetter:
type: string
title: Drive Letter
pattern: '^[D-Zd-z]{1}
Step 2: Define the Resources and Map Disks
In your blueprint’s resources
section, define a vSphere machine and dynamically attach the disk definitions:
resources:
Cloud_vSphere_Machine_1:
type: Cloud.vSphere.Machine
properties:
imageRef: server-2022
cpuCount: 2
totalMemoryMB: 4096
remoteAccess:
authentication: usernamePassword
username: Administrator
password: password!
cloudConfig: |
Content-Type: multipart/mixed; boundary="==NewPart=="
MIME-Version: 1.0
set_hostname: ${self.resourceName}
--==NewPart==
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="VM-init.ps1"
#ps1_sysnative
$diskConfig = @'
${to_json(input.additionalDisks)}
'@ | ConvertFrom-Json
$arrNewDisks = Get-Disk | Where-Object { $_.OperationalStatus -eq "Offline" -and $_.PartitionStyle -eq "RAW" }
$arrNewDisks = $arrNewDisks | Sort-Object Number
$diskConfig = $diskConfig | Sort-Object diskUnit
for ($i = 0; $i -lt $arrNewDisks.Count; $i++) {
$disk = $arrNewDisks[$i]
if ($i -lt $diskConfig.Count) {
$driveLetter = $diskConfig[$i].driveLetter
$label = $diskConfig[$i].diskLabel
Write-Host "Initializing disk $($disk.Number) as $driveLetter: labeled $label"
$partition = $disk | Initialize-Disk -PartitionStyle GPT -PassThru |
New-Partition -DriveLetter $driveLetter -UseMaximumSize
Format-Volume -DriveLetter $driveLetter -FileSystem NTFS -NewFileSystemLabel $label -Confirm:$false
}
}
$drives = Get-WmiObject Win32_Volume -Filter "DriveType=5"
$drives | ForEach-Object {
(New-Object -ComObject Shell.Application).Namespace(17).ParseName($_.Name).InvokeVerb("Eject")
} -ErrorAction SilentlyContinue
attachedDisks: ${map_to_object(resource.Disks[*].id, "source")}
customizeGuestOs: false
constraints:
- tag: env:vSphere
Disks:
type: Cloud.vSphere.Disk
allocatePerInstance: true
properties:
capacityGb: ${input.additionalDisks[count.index].diskSize}
SCSIController: ${input.additionalDisks[count.index].diskController}
unitNumber: ${input.additionalDisks[count.index].diskUnit}
count: ${length(input.additionalDisks)}
Step 3: Deploy Your Blueprint
Once your blueprint is created and saved:
- Deploy a new VM using this template.
- When prompted, fill in values for the additional disks — for example:
[
{
"diskUnit": 1,
"diskSize": 50,
"driveLetter": "E",
"diskLabel": "Data1"
},
{
"diskUnit": 2,
"diskSize": 100,
"driveLetter": "F",
"diskLabel": "Logs"
}
]
- After deployment, log in to the VM and verify that:
- Drives
E:
andF:
exist - They are properly formatted
- The labels are “Data1” and “Logs” respectively
- Drives
Conclusion: Automating Windows Disks with Drive Letter Control
This blueprint setup allows for complete flexibility in how extra disks are handled during provisioning in Aria Automation. Whether you’re creating SQL servers, app VMs, or log collectors — giving users the power to assign drive letters and labels during deployment streamlines the provisioning process.