Hi All,
We often log the errors/information warning while running the scripts in PowerShell. If we have the function , then it is better to call them where ever we need it in script instead of repeatedly adding the logging code.
## function for writelogs
function WriteLogs($LogMessage, $LogType)
{
$LoggingDateTime=get-date;
write-host
"$LogType, ["+
$LoggingDateTime
+"]:"+ $LogMessage | Add-Content -Path $LogFilepath
}
You can call this function like below
WriteLogs "***Installation failed: *** " "Error"
Regards,
Chaitanya