Public/Connect-MSPBackupProcess.ps1

Function Connect-MSPBackupProcess {
    <#
        .SYNOPSIS
            Setup connection to functional process.
 
            Using this command alone doesn't make sense, it should always precede other commands in the same command line
            invocation. It allows you to modify default values used to connect to functional process.
        .DESCRIPTION
            Setup connection to functional process.
 
            Using this command alone doesn't make sense, it should always precede other commands in the same command line
            invocation. It allows you to modify default values used to connect to functional process.
        .PARAMETER HostName
            Host address of running functional process. Default is "127.0.0.1".
        .PARAMETER Password
            Password to use to connect to functional process. Default is taken from config.ini, or is an empty string otherwise.
        .PARAMETER Port
            Port number of running functional process. Default is taken from config.ini, or is an empty string otherwise.
        .PARAMETER TimeOut
            Number of seconds to wait for functional process response. Default is 120.
        .PARAMETER UserName
            Username to use to connect to functional process. Default is taken from config.ini, or is an empty string otherwise.
        .INPUTS
            None
        .OUTPUTS
            None
        .EXAMPLE
            Connect-MSPBackupProcess
        .LINK
            about_functions_advanced
        .LINK
            about_CommonParameters
    #>

    [CmdletBinding()]
    [OutputType('System.String')]
    Param(
        [String]$HostName = "127.0.0.1",
        [securestring]$Password,
        [Int]$Port,
        [Int]$TimeOut = 120,
        [String]$UserName
    )
    Begin {
        Write-Verbose ('{0}:: Function started' -f $MyInvocation.MyCommand)
        $stdOutTempFile = [System.IO.Path]::GetTempFileName()
        $stdErrTempFile = [System.IO.Path]::GetTempFileName()
    }
    Process {
        Write-Verbose ('{0}:: Getting status' -f $MyInvocation.MyCommand)
        $Status = & $Script:CmdPath -machine-readable fp
    }
    End {
        Write-Verbose ('{0}:: Function ended' -f $MyInvocation.MyCommand)
        Return $Status
    }
}