Created
July 22, 2022 05:51
-
-
Save maxautomation/addbdc4f39448a32a634ae1208740f73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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