Out-Default.ps1

function Out-Default {
    [CmdletBinding()]    
    param(
        
    [Parameter(ValueFromPipeline=$true)]
    [psobject]
    $InputObject
    )
    
    begin {
        $global:lastOutputCollection = New-Object Collections.ArrayList
        try {
             $outBuffer = $null
             if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
             {
                 $PSBoundParameters['OutBuffer'] = 1
             }
             $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Out-Default', [System.Management.Automation.CommandTypes]::Cmdlet)
             $scriptCmd = {& $wrappedCmd @PSBoundParameters }
             $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
             $steppablePipeline.Begin($true)
         } catch {
             throw
         }
         $invocation = Get-PSCallStack
    }
    
    process {
        try {
            $willProcess = $true 
            if ($_ -is [Management.Automation.ErrorRecord]) {
                $e = $_ 
                $i = $invocation

<#
                $cs = Get-PSCallStack
                $lastAction = Get-History -Count 1
                if ($lastAction.CommandLine -like "*http*") {
                    if ($lastAction.CommandLine -like "`$*=*http*") {
                        $maybeUrl = $lastAction.CommandLine.Substring($lastAction.CommandLine.IndexOf("=") + 1).Trim()
                        $variableName = $lastAction.CommandLine.Substring(0, $lastAction.CommandLine.IndexOf("=") - 1).TrimStart('$')
                        if ($maybeUrl -like "http*") {
                            Set-Variable -Name $variableName -Value (
                                Get-Web -UseWebRequest $maybeUrl
                            ) -Option AllScope
                        }
                    } else {
                        Start-Process -FilePath $lastAction.CommandLine
                    }
                }
                $null = $null
                #>

             }
             $steppablePipeline.Process($_)
             $null = $global:lastOutputCollection.Add($_)
             $global:lastOutputItem = $_
        } catch {
             throw
        }
                     

    }
    
    end {
        if ($global:lastOutputCollection.Count) {
        $global:LastOutput = $global:lastOutputCollection        
        }
        
        try {
             $steppablePipeline.End()
        } catch {
             throw
        }

    }
}