Skip to content

Instantly share code, notes, and snippets.

@maxautomation
Created July 22, 2022 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maxautomation/addbdc4f39448a32a634ae1208740f73 to your computer and use it in GitHub Desktop.
Save maxautomation/addbdc4f39448a32a634ae1208740f73 to your computer and use it in GitHub Desktop.
Function Get-Device() {
param(
[parameter (mandatory=$true)][string] $InstanceId
)
$CurrentDevice = Get-EC2InstanceAttribute $InstanceId -Attribute blockDeviceMapping | Select-Object -ExpandProperty BlockDeviceMappings | Select-Object -last 1
If ($CurrentDevice.DeviceName -eq '/dev/sda1') {
$NewDevice = 'xvdf'
return $NewDevice
}
Else {
$a = $CurrentDevice.DeviceName.ToCharArray()
$inc = +1
$a[3] = [char]([int]($a[3])+$inc)
$NewDevice = -join $a
return $NewDevice
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment