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 SubProcessStart. Switch to determine type of comment. Only StartProcess (default) returns the datetime to calculate duration. #> function Write-StartProcessLine { param ( [parameter(Mandatory=$true)] [string] $StartLogText, [ValidateSet("StartProcess", "StartSubProcess", "InformationOnly")] [string] $Type = 'StartProcess' ) PROCESS { switch ($Type) { '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 } } } } |