I got an EC2, create with Terraform, with 7 disks (1 root and 6 EBS). As Terraform create and attach my disk on my EC2 randomly I can't base my user data on the partition number for the disk initialisation/volume creation and format.
So I wanted to create a powershell what will be capable get my disk number and process all actions dynamically. The details of my disk are as followed :
| Disk_Name | Disk_letter | Size |
|---|---|---|
| MSSQL_System | D | 50 GB |
| MSSQL_Data | E | 500 GB |
| MSSQL_Log | F | 500 GB |
| MSSQL_TempDB | G | 500 GB |
| MSSQL_Backup | H | 500 GB |
As all disk have the same config (type=gp3/iops/etc) I don't care if the D is the 1st or the 2sd 50GB disk.
I tried
Get-Disk | Where-Object{$_.PartitionStyle -eq 'RAW' -and $_.TotalSize -eq '50 GB'} to filter the 50GB disks and create a partition, but I wasn't able to filter them