I wrote a script in powershell and I would like to have it write all activities and errors to a log file. I am a powershell newbie so I need anyone's input.
I created a function
function logWrite
{
param ([string]$logstring)
add-content $logfile -value $logstring
}
Instead of using Write-host i use the logWrite but I am getting errors:
Unexpected token 'starting script' in expression or statement. at d:\scripts\tmain.ps1
Appreciate everyone's feedback in advance.