Execution Flow
Requires
master.dbo.sqm_BackupExclude to already exist (run Sync-sqmBackupExcludeTable first). Trigger errors never abort CREATE DATABASE or DROP DATABASE — failures are written to the SQL Server error log only. To update the trigger, use -Remove then call again without it.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL instance. Default: $env:COMPUTERNAME. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential. |
| -IncludeSystemDatabases | Switch | Optional | Also auto-tracks master, model, msdb (not recommended for standard installs). |
| -Remove | Switch | Optional | Drops the trigger instead of creating it (propagated to secondaries). |
| -SkipAlwaysOnPropagation | Switch | Optional | Skips recursive registration on AG secondary replicas. |
| -EnableException | Switch | Optional | Throws terminating errors instead of returning an error status object. |
| -WhatIf / -Confirm | Switch | Optional | Standard ShouldProcess support. |
Return Value
Returns an array of PSCustomObject (one per instance processed), each with: SqlInstance, TriggerName, Action (Created / Removed / AlreadyExists / NotFound / WhatIfSkipped / Error / Secondary_*), Message.
Examples
Example 1 — Register trigger on local instance
Register-sqmBackupExcludeTrigger -SqlInstance "SQL01"
Example 2 — Remove and re-register (update trigger)
Register-sqmBackupExcludeTrigger -SqlInstance "SQL01" -Remove
Register-sqmBackupExcludeTrigger -SqlInstance "SQL01"