Execution Flow
Requires
master.dbo.sqm_BackupExclude to exist — run Sync-sqmBackupExcludeTable first. All three steps (create login, create user, grant) honor ShouldProcess, so -WhatIf shows the full planned chain without executing it.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL instance. Default: $env:COMPUTERNAME. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential. |
| -LoginName | String | Required | Windows group (e.g. DOMAIN\DBA-Team) or SQL login to grant permissions to. |
| -EnableException | Switch | Optional | Throws terminating errors instead of logging a warning. |
| -WhatIf / -Confirm | Switch | Optional | Standard ShouldProcess support. |
Return Value
Returns a PSCustomObject with: SqlInstance, LoginName, LoginCreated, UserCreated, PermissionsGranted, Status, Message.
Examples
Example 1 — Grant permissions to a Windows group
Set-sqmBackupExcludePermission -SqlInstance "SQL01" -LoginName "CONTOSO\DBA-Team"
Example 2 — Preview without changes
Set-sqmBackupExcludePermission -SqlInstance "SQL01" -LoginName "CONTOSO\DBA-Team" -WhatIf