:::: MENU ::::

Logging function in powershell


Function LogWrite {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]
$sLogMsg
)
PROCESS {
# Populate the variables to log

$sTime = (Get-Date -Format HH:mm:ss) + ".000+000"
$sDate = Get-Date -Format MM-dd-yyyy
$sTempMsg = "<![LOG[$sLogMsg]LOG]!><time=""$sTime"" date=""$sDate"" component=""$Component"" context="""" type="""" thread="""" file=""$Component"">"

# Create the component log entry

Write-Output $sTempMsg | Out-File -FilePath $logFile -Encoding "Default" -Append

}
} # End of Create-LogEntry function


One Comment

So, what do you think ?