Public/Connect-SwInfoServiceProxy.ps1

Function Connect-SwInfoServiceProxy {
    <#
        .SYNOPSIS
        Connect to a solarwinds server and return proxy object
 
        .DESCRIPTION
        This function gets solarwinds server name and a credential, after that start to create a connection to that server and return a Info Service proxy object.
 
        .EXAMPLE
        PS> Connect-SWInfoServiceProxy -SolarServerName MainPollerServer.Contoso.com -Credential $MyCred
 
        OperationTimeout Channel ClientChannel ChannelFactory
        ---------------- ------- ------------- --------------
        01:00:00 System.ServiceModel.ChannelFactory`1[SolarWinds.InformationService.Contract2.IStreamInformationServiceChannel]
    #>

    [CmdletBinding()]
    [OutputType([System.String])]
    Param (
        [Parameter(Mandatory = $true)]
        [string]$SolarServerName,

        [System.Management.Automation.PSCredential]$Credential
    )

    if($Credential){
        $cred = $Credential
    }
    else{
        $userName = whoami
        $cred = Get-Credential -UserName $userName -Message "Enter your credentials."
    }

    Write-Verbose -Message "Connecting to Solarwinds service ... "
    $swis = Connect-Swis -Hostname $SolarServerName -Credential $cred

    return ($swis)
}