I created a powershell script (AD-Mapping) which runs as scheduled task. Inside this script I want to check for different errors which I would like to write in the EventLog which is automatically created with the task visible inside the tab history.
I know, I can create my own event log with New-EventLog
and Write-EvengLog
. But how can I use the already existing one?
When I check the existing Event Logs with Get-EventLog *
I can see my custom one but I can’t find the EventLog from my Scheduled Task.
PS C:Users**** Get-EventLog *
Max(K) Retain OverflowAction Entries Log
------ ------ -------------- ------- ---
512 7 OverwriteOlder 1 AD-Mapping Eventlog
20’480 0 OverwriteAsNeeded 60’860 Application
20’480 0 OverwriteAsNeeded 0 HardwareEvents
512 7 OverwriteOlder Internet Explorer
20’480 0 OverwriteAsNeeded 0 Key Management Service
128 0 OverwriteAsNeeded 1’336 OAlerts
Security
20’480 0 OverwriteAsNeeded 92’230 System
15’360 0 OverwriteAsNeeded 13’103 Windows PowerShell
PS C:Users****> Get-EventLog Microsoft-Windows-TaskScheduler/Operational
Get-EventLog : The event log 'Microsoft-Windows-TaskScheduler/Operational' on computer '.' does not exist.
At line:1 char:1
+ Get-EventLog Microsoft-Windows-TaskScheduler/Operational
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-EventLog], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand
And I also can’t find any way to write into this one. What’s the difference between the EventLogs from Get-EventLog and the EventLog form the History in the Task Scheduler?
pikesquare is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.