91 lines
3.5 KiB
PowerShell
91 lines
3.5 KiB
PowerShell
|
function Get-WorkspaceBundleList {
|
||
|
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Get a list of AWS Workspace bundles.
|
||
|
|
||
|
.DESCRIPTION
|
||
|
Get a list of AWS Workspace bundles. This is a convenience wrapper around the AWS PowerShell cmdlet
|
||
|
'Get-WKSWorkspaceBundle' to provide filtering options needed by the System Engineering team.
|
||
|
|
||
|
.PARAMETER ProfileName
|
||
|
[string] The AWS profile to use for the operation. If not provided, will default to 'temp-workspaces'.
|
||
|
|
||
|
.PARAMETER Region
|
||
|
[string] The AWS region to use for the operation. If not provided, will default to 'us-west-2'.
|
||
|
|
||
|
.PARAMETER Owner
|
||
|
[string] The Workspace bundle owner. If not provided, will default to 'Alkami'.
|
||
|
|
||
|
.PARAMETER ComputeTypeFilter
|
||
|
[string] Filter to apply to the Workspace bundle list to limit results to a specific compute type.
|
||
|
If not provided, no compute type filtering will be applied.
|
||
|
|
||
|
.PARAMETER OsFilter
|
||
|
[string] Filter to apply to the Workspace bundle list to limit results to a specific operating system.
|
||
|
If not provided, no operating system type filtering will be applied. Note that this relies on the Name
|
||
|
of the bundle containing the operating system.
|
||
|
|
||
|
.PARAMETER ProtocolFilter
|
||
|
[string] Filter to apply to the Workspace bundle list to limit results to a specific protocol.
|
||
|
If not provided, no protocol filtering will be applied. Note that this relies on the Description
|
||
|
of the bundle containing the protocol string.
|
||
|
|
||
|
.EXAMPLE
|
||
|
Get-WorkspaceBundleList
|
||
|
# An array of Alkami bundles.
|
||
|
|
||
|
.EXAMPLE
|
||
|
Get-WorkspaceBundleList -Owner 'Amazon' -ComputeTypeFilter 'STANDARD' -OsFilter 'Windows 10' -ProtocolFilter 'WorkSpaces Streaming Protocol'
|
||
|
# An array of AWS-produced WSP Standard Windows 10 bundles.
|
||
|
#>
|
||
|
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([PSObject[]])]
|
||
|
param (
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateNotNullOrEmpty()]
|
||
|
[string] $ProfileName = 'temp-workspaces',
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateScript({$_ -in (Get-AWSRegion).region})]
|
||
|
[string] $Region = 'us-west-2',
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateSet('Alkami', 'Amazon')]
|
||
|
[string] $Owner = 'Alkami',
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateSet('GRAPHICS', 'GRAPHICSPRO', 'PERFORMANCE', 'POWER', 'POWERPRO', 'STANDARD', 'VALUE_TYPE')]
|
||
|
[string] $ComputeTypeFilter = $null,
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateSet('Windows 10', 'Amazon Linux 2')]
|
||
|
[string] $OsFilter = $null,
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateSet('WorkSpaces Streaming Protocol', 'PCoIP')]
|
||
|
[string] $ProtocolFilter = $null
|
||
|
)
|
||
|
|
||
|
Import-AWSModule
|
||
|
|
||
|
# To filter to Alkami's bundles, we omit the 'Owner' parameter.
|
||
|
$splatParams = @{}
|
||
|
if ( $Owner -eq 'Amazon' ) {
|
||
|
$splatParams["Owner"] = "AMAZON"
|
||
|
}
|
||
|
|
||
|
# List the bundles using the AWS API. All of the filtering other than Owner must be done after-the-fact because
|
||
|
# AWS decided to give us no capabilities on this API endpoint.
|
||
|
$list = Get-WKSWorkspaceBundle -ProfileName $ProfileName -Region $Region @splatParams
|
||
|
|
||
|
# Apply any provided filters to the list.
|
||
|
$filteredList = $list | Where-Object {
|
||
|
(( [string]::IsNullOrEmpty( $ComputeTypeFilter ) -or ( $_.ComputeType.Name -eq $ComputeTypeFilter )) -and `
|
||
|
( [string]::IsNullOrEmpty( $OsFilter ) -or ( $_.Name -match $OsFilter )) -and `
|
||
|
( [string]::IsNullOrEmpty( $ProtocolFilter ) -or ( $_.Description -match $ProtocolFilter )))
|
||
|
}
|
||
|
|
||
|
return $filteredList
|
||
|
}
|