private/Write-LogMessage.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
function Write-LogMessage { [CmdletBinding()] param ( # Parameter help description [Parameter(Mandatory = $true)] [String] $Message, # Parameter help description [Parameter(Mandatory = $false)] [ValidateSet('Verbose', 'Output')] [String] $Type = 'Verbose' ) begin { } process { $text = "$(Get-Date -UFormat "%Y/%m/%d %T"): $(((Get-PSCallStack).Command)[1]): $Message" switch ($Type) { Output { Write-Output -InputObject $text } Verbose { Write-Verbose -Message $text } } } end { } } |