Skip to content

Set‑SqlDscAudit

dscbot edited this page Oct 26, 2024 · 1 revision

SYNOPSIS

Updates a server audit.

SYNTAX

ServerObjectWithSizeAndMaxRolloverFiles

Set-SqlDscAudit -ServerObject <Server> -Name <String> [-AuditFilter <String>] [-OnFailure <String>]
 [-QueueDelay <UInt32>] [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>]
 -MaximumFileSize <UInt32> -MaximumFileSizeUnit <String> -MaximumRolloverFiles <UInt32>
 [-WhatIf] [-Confirm] [<CommonParameters>]

ServerObjectWithSizeAndMaxFiles

Set-SqlDscAudit -ServerObject <Server> -Name <String> [-AuditFilter <String>] [-OnFailure <String>]
 [-QueueDelay <UInt32>] [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>]
 -MaximumFileSize <UInt32> -MaximumFileSizeUnit <String> -MaximumFiles <UInt32> [-ReserveDiskSpace]
 [-WhatIf] [-Confirm] [<CommonParameters>]

ServerObjectWithMaxRolloverFiles

Set-SqlDscAudit -ServerObject <Server> -Name <String> [-AuditFilter <String>] [-OnFailure <String>]
 [-QueueDelay <UInt32>] [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>]
 -MaximumRolloverFiles <UInt32> [-WhatIf] [-Confirm] [<CommonParameters>]

ServerObjectWithMaxFiles

Set-SqlDscAudit -ServerObject <Server> -Name <String> [-AuditFilter <String>] [-OnFailure <String>]
 [-QueueDelay <UInt32>] [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>]
 -MaximumFiles <UInt32> [-ReserveDiskSpace] [-WhatIf] [-Confirm]
 [<CommonParameters>]

ServerObjectWithSize

Set-SqlDscAudit -ServerObject <Server> -Name <String> [-AuditFilter <String>] [-OnFailure <String>]
 [-QueueDelay <UInt32>] [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>]
 -MaximumFileSize <UInt32> -MaximumFileSizeUnit <String> [-WhatIf]
 [-Confirm] [<CommonParameters>]

ServerObject

Set-SqlDscAudit -ServerObject <Server> -Name <String> [-AuditFilter <String>] [-OnFailure <String>]
 [-QueueDelay <UInt32>] [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>]
 [-WhatIf] [-Confirm] [<CommonParameters>]

AuditObjectWithSizeAndMaxRolloverFiles

Set-SqlDscAudit -AuditObject <Audit> [-AuditFilter <String>] [-OnFailure <String>] [-QueueDelay <UInt32>]
 [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>] -MaximumFileSize <UInt32>
 -MaximumFileSizeUnit <String> -MaximumRolloverFiles <UInt32> [-WhatIf]
 [-Confirm] [<CommonParameters>]

AuditObjectWithSizeAndMaxFiles

Set-SqlDscAudit -AuditObject <Audit> [-AuditFilter <String>] [-OnFailure <String>] [-QueueDelay <UInt32>]
 [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>] -MaximumFileSize <UInt32>
 -MaximumFileSizeUnit <String> -MaximumFiles <UInt32> [-ReserveDiskSpace] 
 [-WhatIf] [-Confirm] [<CommonParameters>]

AuditObjectWithMaxRolloverFiles

Set-SqlDscAudit -AuditObject <Audit> [-AuditFilter <String>] [-OnFailure <String>] [-QueueDelay <UInt32>]
 [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>] -MaximumRolloverFiles <UInt32>
 [-WhatIf] [-Confirm] [<CommonParameters>]

AuditObjectWithMaxFiles

Set-SqlDscAudit -AuditObject <Audit> [-AuditFilter <String>] [-OnFailure <String>] [-QueueDelay <UInt32>]
 [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>] -MaximumFiles <UInt32>
 [-ReserveDiskSpace] [-WhatIf] [-Confirm] [<CommonParameters>]

AuditObjectWithSize

Set-SqlDscAudit -AuditObject <Audit> [-AuditFilter <String>] [-OnFailure <String>] [-QueueDelay <UInt32>]
 [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>] -MaximumFileSize <UInt32>
 -MaximumFileSizeUnit <String> [-WhatIf] [-Confirm] [<CommonParameters>]

AuditObject

Set-SqlDscAudit -AuditObject <Audit> [-AuditFilter <String>] [-OnFailure <String>] [-QueueDelay <UInt32>]
 [-AuditGuid <String>] [-Force] [-Refresh] [-PassThru] [-Path <String>] 
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This command updates and existing server audit on a SQL Server Database Engine instance.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$sqlServerObject | Set-SqlDscAudit -Name 'MyFileAudit' -Path 'E:\auditFolder' -QueueDelay 1000

Updates the file audit named MyFileAudit by setting the path to ''E:\auditFolder' and the queue delay to 1000.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$sqlServerObject | New-SqlDscAudit -Name 'MyAppLogAudit' -QueueDelay 1000

Updates the application log audit named MyAppLogAudit by setting the queue delay to 1000.

EXAMPLE 3

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$sqlServerObject | Set-SqlDscAudit -Name 'MyFileAudit' -Path 'E:\auditFolder' -QueueDelay 1000 -PassThru

Updates the file audit named MyFileAudit by setting the path to ''E:\auditFolder' and the queue delay to 1000, and returns the Audit object.

PARAMETERS

-AuditFilter

Specifies the filter that should be used on the audit. See predicate expression how to write the syntax for the filter.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AuditGuid

Specifies the GUID found in the mirrored database. To support scenarios such as database mirroring an audit needs a specific GUID.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AuditObject

Specifies an audit object to update.

Type: Audit
Parameter Sets: AuditObjectWithSizeAndMaxRolloverFiles, AuditObjectWithSizeAndMaxFiles, AuditObjectWithMaxRolloverFiles, AuditObjectWithMaxFiles, AuditObjectWithSize, AuditObject
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Force

Specifies that the audit should be updated without any confirmation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-MaximumFiles

Specifies the number of files on disk.

Type: UInt32
Parameter Sets: ServerObjectWithSizeAndMaxFiles, ServerObjectWithMaxFiles, AuditObjectWithSizeAndMaxFiles, AuditObjectWithMaxFiles
Aliases:

Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-MaximumFileSize

Specifies the maximum file size in units by parameter MaximumFileSizeUnit. Minimum allowed value is 2 (MB). It also allowed to set the value to 0 which mean unlimited file size.

Type: UInt32
Parameter Sets: ServerObjectWithSizeAndMaxRolloverFiles, ServerObjectWithSizeAndMaxFiles, ServerObjectWithSize, AuditObjectWithSizeAndMaxRolloverFiles, AuditObjectWithSizeAndMaxFiles, AuditObjectWithSize
Aliases:

Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-MaximumFileSizeUnit

Specifies the unit that is used for the file size. this can be KB, MB or GB.

Type: String
Parameter Sets: ServerObjectWithSizeAndMaxRolloverFiles, ServerObjectWithSizeAndMaxFiles, ServerObjectWithSize, AuditObjectWithSizeAndMaxRolloverFiles, AuditObjectWithSizeAndMaxFiles, AuditObjectWithSize
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MaximumRolloverFiles

Specifies the amount of files on disk before SQL Server starts reusing the files. If not specified then it is set to unlimited.

Type: UInt32
Parameter Sets: ServerObjectWithSizeAndMaxRolloverFiles, ServerObjectWithMaxRolloverFiles, AuditObjectWithSizeAndMaxRolloverFiles, AuditObjectWithMaxRolloverFiles
Aliases:

Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Name

Specifies the name of the server audit to be updated.

Type: String
Parameter Sets: ServerObjectWithSizeAndMaxRolloverFiles, ServerObjectWithSizeAndMaxFiles, ServerObjectWithMaxRolloverFiles, ServerObjectWithMaxFiles, ServerObjectWithSize, ServerObject
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-OnFailure

Specifies what should happen when writing events to the store fails. This can be 'Continue', 'FailOperation', or 'Shutdown'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

If specified the changed audit object will be returned.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Path

Specifies the location where te log files wil be placed.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-QueueDelay

Specifies the maximum delay before a event is written to the store. When set to low this could impact server performance. When set to high events could be missing when a server crashes.

Type: UInt32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Refresh

Specifies that the audit object should be refreshed before updating. This is helpful when audits could have been modified outside of the ServerObject, for example through T-SQL. But on instances with a large amount of audits it might be better to make sure the ServerObject is recent enough.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ReserveDiskSpace

Specifies if the needed file space should be reserved. To use this parameter the parameter MaximumFiles must also be used.

Type: SwitchParameter
Parameter Sets: ServerObjectWithSizeAndMaxFiles, ServerObjectWithMaxFiles, AuditObjectWithSizeAndMaxFiles, AuditObjectWithMaxFiles
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: ServerObjectWithSizeAndMaxRolloverFiles, ServerObjectWithSizeAndMaxFiles, ServerObjectWithMaxRolloverFiles, ServerObjectWithMaxFiles, ServerObjectWithSize, ServerObject
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

[Microsoft.SqlServer.Management.Smo.Audit] is passing parameter PassThru,

otherwise none.

NOTES

This command has the confirm impact level set to high since an audit is unknown to be enable at the point when the command is issued.

See the SQL Server documentation for more information for the possible parameter values to pass to this command: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-audit-transact-sql

RELATED LINKS

Home

Commands

Resources

Usage

Clone this wiki locally