Changing Audit Policies through scripting

Anthony Redgrave
Anthony Redgrave used Ask the Experts™
on
Within the Local Security Policies on Windows, there's a category called Audit Policies. I'm trying to write a script that is capable of changing all the audit policies to success and failure, however I can't seem to figure out how to do it. I don't want to change the Advanced audit policies, just the audit policies under local policies in the Local Security Policy application. If that's possible through any scripting language, feel free to leave an example, and if it's not possible, could somebody please let me know, this has been bothering me awhile and I would like to get it out of the way. Thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Erik BjersPrincipal Systems Administrator

Commented:
If you have a domain you are better off doing this through group policy which can be applied to the entire domain or to a specific (or multiple) OU

The GPO settings are the same as the local security policy.
Distinguished Expert 2018
Commented:
Sure, GPOs are preferably used. If not possible:
Type
auditpol /set /?
at the command prompt.

Author

Commented:
I've already tried using the auditpol command. Although it works perfectly for the Advanced audit policies, it doesn't work for the ones just under local policies which is what I'm trying to change. Of course, I could just be entering the command wrong, but regardless, it's still bothersome.  I am not trying to set advanced audit policies, just the ones under local policies
Distinguished Expert 2018
Commented:
Works here when I execute those on win10, at the moment I have no access to win7.
Let's execute one together:
auditpol /set /user:yourusername /Category:"System" /success:enable /include
(you should of course use domainname\yourusername instead of just username if on a domain. Then again, if on a domain, why not take GPOs for this task?).
auditpol /set /Category:"System" /success:enable
Afterwards, open secpol.msc and find that auditing of system events is activated for success.

Author

Commented:
Thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial