Create a custom Security log event?
Is there any way to create a custom Security Log event using VBscript or PowerShell? Everything I've tried so far produces "Access Denied" errors (e.g. I've been testing the EventCreate command in a CMD prompt and write-eventlog in PowerShell, which have all failed so far. I've been testing the commands prior to attempting to get something similar to work in a script).  (Note: running commands as System via a scheduled task to try and get past the Access Denied errors hasn't worked yet either.)   Thanks!
January 28th, 2015 1:08am

You have to run elevated to access the security log with any tool.

Free Windows Admin Tool Kit Click here and download it now
January 28th, 2015 2:33am

I see you have tried to run it as System.

Maybe this will help understand the permissions required:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363658%28v=vs.85%29.aspx

Can you write to other event logs?  can you post what you have for code so far?


  • Edited by CountryStyle Wednesday, January 28, 2015 1:08 AM
January 28th, 2015 4:05am

To start with, I was just trying to see if I could get a basic command to run successfully before spending the time to put it in code.  For example, I setup a scheduled task to run as System, and run the following:

Powershell -Command "& {write-eventlog -logname Security -source Microsoft-Windows-Security-Auditing -eventID 777 -entrytype Information -message "Did-it-work?"}"

Running the task didn't result in any Security Events being created.  

If I try running that from an admin CMD prompt, I get the following:

C:\Windows\system32>powershell -Command "& {write-eventlog -logname Security -so
urce Microsoft-Windows-Security-Auditing -eventID 777 -entrytype Information -me
ssage "Did-it-work?"}"
write-eventlog : The registry key for the log "Security" for source
"Microsoft-Windows-Security-Auditing" could not be opened.
At line:1 char:4
+ & {write-eventlog -logname Security -source
Microsoft-Windows-Security-Auditing  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : PermissionDenied: (:) [Write-EventLog], Exception
    + FullyQualifiedErrorId : AccessDenied,Microsoft.PowerShell.Commands.Write
   EventLogCommand


Free Windows Admin Tool Kit Click here and download it now
January 31st, 2015 12:41am

I recommend learning how to read the error messages:

  + CategoryInfo          : PermissionDenied: (:) [Write-EventLog], Exception

You do not have permission. The security log is not an application log. Use the Application log for simple status logging.  The security log is for special things not including scripting.

January 31st, 2015 12:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics