Skip to content

Instantly share code, notes, and snippets.

@Niqq787
Forked from maxautomation/GetDevice.ps1
Created April 26, 2024 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Niqq787/622e6b63c05eb3bc1e0e97c76f4c8596 to your computer and use it in GitHub Desktop.
Save Niqq787/622e6b63c05eb3bc1e0e97c76f4c8596 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