I have a powershell script which i would like to add to the eventlog.
When i type in the Write-Eventlog command i get a error message.
Write-EventLog -Logname autosnapshot -Source 'D:\script autoSnapshots.ps1' -EventId 8000 -Entrytype Information -Message 'Creates Snapshots and deletes snapshots older than 1 day'
I though the syntax was correct but I get a error message.
Write-EventLog: The term 'Write-EventLog' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Does anybody know what I am doing wrong?
Any help is appreciated.
The answer was given in the comments to the question, but as Jonathan pointed out, it should be an answer. Especially for the sake of anyone that might fail to read the comments.
Mathias' comment "Write-EventLog is only available in Windows PowerShell (version 5.1 or older)" is correct.
I found this: Due to the use of unsupported APIs, the -EventLog cmdlets have been removed from PowerShell. Get-WinEvent and New-WinEvent are available to get and create events on Windows on this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With