Public/func_Get-SSHServer.ps1


function Get-SSHServer {
    [CmdletBinding()]
    param (
        [Parameter(Position = 0, Mandatory = $false)][string[]]$Tags,
        [Parameter(Position = 1, Mandatory = $false)][string]$Name,
        [Parameter(Position = 2, Mandatory = $false)][Switch]$IP
    )
    [Collections.Generic.List[SSHServer]]$sshServers = Get-SSHServersFile
    $result = $sshServers
    if($null -ne $Tags)
    {
        foreach ($tag in $Tags) {
            $result = $result | Where-Object Tags -Contains $tag
        }
    }
    if(![string]::IsNullOrWhiteSpace($Name))
    {
        $result = $result | Where-Object Name -Like $Name
    }
    if($IP.IsPresent)
    {
        $result = $($result.IP)
    }
    return $result
}