Simple PowerShell Log Function
Just to share it somewhere with someone, following my powershell basic log function.
Function Log-Message {
[cmdletbinding()]
Param (
[parameter(Mandatory=$true)] [string] $Message,
[string] $LogLevel = "info"
)
$currentDate = Get-Date -Format "yyyyMMdd"
$currentTime = Get-Date -Format "HHmmss"
$logMessage = '{0} {1} [{2}]: {3}' -f $currentDate,$currentTime,$logLevel,$message
$logMessage >> $logFile
}
Enjoy it.
Trackbacks
The author does not allow comments to this entry
Comments
Display comments as Linear | Threaded