So I've run the following code on one of my servers to create a custom event log and source:
New-EventLog -LogName psLogs -source scripts
Limit-EventLog -overflowaction overwriteasneeded -maximumsize 1MB -logname psLogs
Write-EventLog -LogName psLogs -Source scripts -Message "PsLogs Event Log Setup Complete!" -EventId 0 -EntryType information
Write-Host "PsLogs Event Log Setup Complete!"
This works fine since I ran it as "Administrator"
Next question is how do I incorporate this Event Log into a script that I am running via task scheduler so that if the scheduled script errors it will output the errors to this log? I would also like to know how to write the Information and Warning types too.
In other words if I run a script that automatically installs printers via a CSV and the thing errors out for any reason I want an entry in my Custom Event Log to appear.