Public/Get-MSPBackupSessionList.ps1

Function Get-MSPBackupSessionList {
    <#
        .SYNOPSIS
            List backup and restore sessions.
        .DESCRIPTION
            List backup and restore sessions. Displays sessions for specific datasource or (if none specified) for all
            datasources. Produces a table with TAB-separated (by default) columns in this order:
                DSRC Datasource name
                TYPE Session type
                STATE Status
                FLAGS Session flags (see below)
                START Start time
                END End time
                SELS Selected size
                SELC Selected files count
                PROCS Processed size
                PROCC Processed files count
                SENTS Sent size
                ERRC Errors count
                REMC Removed files count
 
            Session start time (fifth column) could further be used to restore files and folders from that specific
            session.
 
            Session flags column could contain following symbols:
                A archived.
        .PARAMETER Datasource
            Datasource to select sessions for. Possible values are BareMetalRestore, Exchange, FileSystem, MySql,
            NetworkShares, Oracle, SystemState, VMware, VirtualDisasterRecovery, VssHyperV, VssMsSql or VssSharePoint.
        .INPUTS
            None
        .OUTPUTS
            None
        .EXAMPLE
            Get-MSPBackupSessionList
        .LINK
            about_functions_advanced
        .LINK
            about_CommonParameters
    #>

    [CmdletBinding()]
    [OutputType('System.String')]
    Param(
        [ValidateSet('FileSystem')]
        [String]$Datasource
    )
    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 control.session.list -no-header -delimiter ';' -datasource $Datasource
    }
    End {
        Write-Verbose ('{0}:: Function ended' -f $MyInvocation.MyCommand)
        Return $Status
    }
}