Functions/Logging/Write-StartProcessLine.ps1

<#
    .SYNOPSIS
    Starts process line to calculate duration. See also Write-EndProcessLine.
    .DESCRIPTION
    Starts process line to calculate duration. See also Write-EndProcessLine.
    .EXAMPLE
    Write-StartProcessLine "start migration"
    .PARAMETER StartLogText
    Text to write in startlog
    .PARAMETER ProcessType.
    Switch to determine type of comment. Only StartProcess (default) returns the datetime to calculate duration.
#>


function Write-StartProcessLine
{
    [CmdletBinding()]
    [Alias('Write-StartTask')]
    param
    (
        [parameter(Mandatory=$true, ValueFromPipeline =$true)]
        [string] $StartLogText,
        [parameter(Mandatory=$false)]
        [ValidateSet("StartProcess", "StartSubProcess", "InformationOnly")]
        [string] $ProcessType = 'StartProcess'
    )
    PROCESS
    {
        switch ($ProcessType) {
            'StartProcess' {
                Write-Host ("{0} <<< {1}.." -f (Get-Date), $StartLogText) -ForegroundColor yellow
                return (Get-Date)
            }
            'StartSubProcess' {
                Write-Host ("{0} < {1}.." -f (Get-Date), $StartLogText) -ForegroundColor White  
            }
            'InformationOnly' {
                Write-Host ("{0}.." -f $StartLogText) -ForegroundColor Green  
            }
        }
    }
}
Export-ModuleMember -Function Write-StartProcessLine -Alias Write-StartTask