Skip to content

Instantly share code, notes, and snippets.

View PatrickKeisler's full-sized avatar

Patrick Keisler PatrickKeisler

View GitHub Profile
@PatrickKeisler
PatrickKeisler / Convert-SqlAudit.ps1
Last active October 14, 2024 21:10
Convert-SqlAudit can be used to convert a SQL audit file using Read-SqlXEvent (from the SqlServer module) to a comma-separated (CSV) file. The values will match the output of the T-SQL function sys.fn_get_audit_file.
<#
.SYNOPSIS
Converts a SQL Server audit file to a CSV file.
.DESCRIPTION
Some third-party tools cannot read audit records directly from a SQLAUDIT file. Those audit files are typically imported
into a SQL database where they can be read by those third-party tools. This script privides an alternative to that option.
.NOTES
This script does requires the SqlServer module version 22.3.0 or greater.