Functions/Instances/Get-CdsInstance.ps1
<#
.SYNOPSIS Retrieve instance #> function Get-CdsInstance { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [String] $Name ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $instances = Get-CdsInstances; $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-CdsInstance -Alias *; |