-
Notifications
You must be signed in to change notification settings - Fork 227
Closed
Labels
enhancementThe issue is an enhancement request.The issue is an enhancement request.
Description
Description
The Set-SqlDscAudit command fails when attempting to modify the AuditGuid property of an existing SQL Server audit object due to SQL Server restrictions.
Error Details
When running the integration test for modifying AuditGuid property, the following error occurs:
SmoException: Modifying the Guid property of the Audit object is not allowed. You must drop and recreate the object with the desired property.
FailedOperationException: Alter failed for Audit 'SqlDscTestSetAudit_983291254'.
MethodInvocationException: Exception calling "Alter" with "0" argument(s): "Alter failed for Audit 'SqlDscTestSetAudit_983291254'. "Steps to Reproduce
- Create an audit using
New-SqlDscAudit - Attempt to modify the AuditGuid property using
Set-SqlDscAudit - The command fails with the above error
Expected Behavior
The command should successfully modify the AuditGuid property, either by:
- Adding an opt-in parameter (e.g.,
-AllowRecreate) toSet-SqlDscAuditthat enables dropping and recreating the audit object with the desired GUID. This should probably be in a parameter set together with parameterAuditGuid. Careful consideration need to be taken when setting other values of the passed parameters to the properties of the new audit object as the re-created object must maintain the exact values of the previous object, plus setting (overwriting) any new values passed in together with theAuditGuidparameter. - Creating a new command (e.g.,
Reset-SqlDscAudit) that supports the recreation pattern for properties that cannot be modified directly
Suggested Solutions
Option 1: Enhance Set-SqlDscAudit
Add an optional parameter like -AllowRecreate that when specified, allows the command to drop and recreate the audit object when encountering properties that cannot be modified directly.
Option 2: New Command
Create a new command Reset-SqlDscAudit that specifically handles the drop-and-recreate pattern for audit objects when direct modification is not supported.
Environment
- Command:
Set-SqlDscAudit - SQL Server: Multiple versions (2017, 2019, 2022)
- Module: SqlServerDsc
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementThe issue is an enhancement request.The issue is an enhancement request.