functions/ui/Add-TimeStamp.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function Add-TimeStamp { [CmdletBinding()] param ( [parameter(Mandatory = $false, ValueFromPipeline = $true)] [string]$Text = $null, [parameter(Mandatory = $false)] [ConsoleColor]$TimeStampColor = 15 # White ) $textWithTimeStamp = "$(Get-Date -Format "MM.dd.yyyy HH:mm:ss") | $Text" if ($null -eq $Text -or "" -eq $Text) { Write-Host $textWithTimeStamp -ForegroundColor $TimeStampColor -NoNewline } else { $textWithTimeStamp } } |