Skip to content

Instantly share code, notes, and snippets.

@Graham-Beer
Created February 26, 2019 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Graham-Beer/68eec211098d64d5186d4b2af04281dd to your computer and use it in GitHub Desktop.
Save Graham-Beer/68eec211098d64d5186d4b2af04281dd to your computer and use it in GitHub Desktop.
function Get-EC2Ami {
[CmdletBinding()]
param (
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
[SupportsWildcards()]
[String] $ImageType,
[Parameter(Mandatory, Position = 1)]
[ArgumentCompleter( { (Get-AWSRegion).Region })]
[String] $Region,
[Parameter(Mandatory, Position = 2)]
[String[]] $Owner
)
begin {
$platformValues = [System.Collections.Generic.List[string]]::new()
}
process {
$platformValues = $ImageType
$filter = [Amazon.EC2.Model.Filter]@{
Name = "name"
Values = $platformValues
}
Get-EC2Image -Owner $Owner -Region $Region -Filter $filter
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment