Functions/Instances/Get-CdsInstance.ps1
<#
.SYNOPSIS Retrieve instance #> function Get-CdsInstance { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [String] $Name, [Parameter(Mandatory = $false)] [ArgumentCompleter( { Get-CdsRegions })] [String] $Region = $Global:CdsContext.Region, [Parameter(Mandatory = $false)] [ArgumentCompleter( { Get-CdsAuthTypes })] [string] $AuthType = $Global:CdsContext.AuthType, [Parameter(Mandatory = $false)] [PsCredential] $Credentials = $Global:CdsContext.Credentials ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $instances = Get-CdsInstances -Region $Region -AuthType $AuthType -Credentials $Credentials; $instance = $instances | Where-Object -Property "Name" -EQ -Value $Name; if(-not $instance) { throw "Instance $Name not found!"; } $instance; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Get-CdsInstances -Alias *; |