Project

AuditPolicy

AuditPolicy module aims to replace auditpol.exe to get or set Auditing Policies in Windows in more native PowerShell way

Stars11
Forks2
Open issues0
PowerShell Gallery downloads23373
Releasev0.0.6
Language: PowerShell Updated: 2026-02-14T21:44:05.0000000+00:00

Curated Examples

Back up and restore audit policy

Save Windows audit policy to a file and test restore paths with WhatIf.

This pattern is useful when audit policy changes need a rollback point.

It is adapted from Examples/BackupAuditPolicies.ps1 and Examples/RestoreAuditPolicies.ps1.

Example

Import-Module AuditPolicy

$backupPath = Join-Path $PSScriptRoot 'Backups\AuditPolicy.json'
New-Item -ItemType Directory -Path (Split-Path $backupPath) -Force | Out-Null

Backup-SystemAuditPolicy | Out-File -FilePath $backupPath

Restore-SystemAuditPolicy -FilePath $backupPath -Verbose -WhatIf
Restore-SystemAuditPolicy -FilePath $backupPath -Policy 'Application Group Management' -Verbose -WhatIf

What this demonstrates

  • keeping a policy backup near the script
  • testing restore behavior before applying it
  • restoring a complete policy file or a selected policy

Source