Chapters/proxy-functions/step2/ConvertToHTMLProxy.ps1

function NewConvertTo-HTML {
[CmdletBinding(DefaultParameterSetName='Page',
 HelpUri='http://go.microsoft.com/fwlink/?LinkID=113290',
 RemotingCapability='None')]
param(
    [Parameter(ValueFromPipeline=$true)]
    [psobject]
    ${InputObject},

    [Parameter(Position=0)]
    [System.Object[]]
    ${Property},

    [Parameter(ParameterSetName='Page', Position=3)]
    [string[]]
    ${Body},

    [Parameter(ParameterSetName='Page', Position=1)]
    [string[]]
    ${Head},

    [Parameter(ParameterSetName='Page', Position=2)]
    [ValidateNotNullOrEmpty()]
    [string]
    ${Title},

    [ValidateNotNullOrEmpty()]
    [ValidateSet('Table','List')]
    [string]
    ${As},

    [Parameter(ParameterSetName='Page')]
    [Alias('cu','uri')]
    [ValidateNotNullOrEmpty()]
    [uri]
    ${CssUri},

    [Parameter(ParameterSetName='Fragment')]
    [ValidateNotNullOrEmpty()]
    [switch]
    ${Fragment},

    [ValidateNotNullOrEmpty()]
    [string[]]
    ${PostContent},

    [ValidateNotNullOrEmpty()]
    [string[]]
    ${PreContent})

begin
{
    try {
        $outBuffer = $null
        if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
        {
            $PSBoundParameters['OutBuffer'] = 1
        }
        $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Utility\ConvertTo-Html',
        [System.Management.Automation.CommandTypes]::Cmdlet)

        # create our css
        $css += @'
        <style>
        th { color:white; background-color: black;}
        body { font-family: Calibri; padding: 2px }
        </style>
'@


        # was -head specified?
        if ($PSBoundParameters.ContainsKey('head')) {
            $PSBoundParameters.head += $css
        } else {
            $PSBoundParameters += @{'Head'=$css}
        }
        
        $scriptCmd = {& $wrappedCmd @PSBoundParameters }
        $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
        $steppablePipeline.Begin($PSCmdlet)
    } catch {
        throw
    }
}

process
{
    try {
        $steppablePipeline.Process($_)
    } catch {
        throw
    }
}

end
{
    try {
        $steppablePipeline.End()
    } catch {
        throw
    }
}
<#
 
.ForwardHelpTargetName Microsoft.PowerShell.Utility\ConvertTo-Html
.ForwardHelpCategory Cmdlet
 
#>

}r))

        {

            $PSBoundParameters['OutBuffer'] = 1

        }

        $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Utility\ConvertTo-Html',

        [System.Management.Automation.CommandTypes]::Cmdlet)



        # create our css

        $css += @' <style> th { color:white; background-color: black;} body { font-family: Calibri; padding: 2px } </style> '@



        # was -head specified?

        if ($PSBoundParameters.ContainsKey('head')) {

            $PSBoundParameters.head += $css

        } else {

            $PSBoundParameters += @{'Head'=$css}

        }

        

        $scriptCmd = {& $wrappedCmd @PSBoundParameters }

        $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)

        $steppablePipeline.Begin($PSCmdlet)

    } catch {

        throw

    }

}



process

{

    try {

        $steppablePipeline.Process($_)

    } catch {

        throw

    }

}



end

{

    try {

        $steppablePipeline.End()

    } catch {

        throw

    }

}

<#



.ForwardHelpTargetName Microsoft.PowerShell.Utility\ConvertTo-Html

.ForwardHelpCategory Cmdlet



#>

}