Set-sqmDatabaseOwner
ConfigurationsqmSQLTool v1.8.2+ · Database Admin⚠ Alters Ownership ✓ Validation
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Required | — | Target SQL Server instance. |
| -SqlCredential | PSCredential | Optional | — | Credentials for the connection. |
| -Database | string[] | Required | — | Target databases (name or wildcard pattern). |
| -NewOwner | string | Required | — | New owner principal name (SQL login or Windows account). |
| -ContinueOnError | switch | Switch | $false | Continue to next database on error. |
| -EnableException | switch | Switch | $false | Re-throw exceptions immediately. |
| -WhatIf / -Confirm | switch | Optional | — | ShouldProcess (ConfirmImpact: Medium) guards ownership change. |
Execution Flow
Examples
Change single database owner
Set-sqmDatabaseOwner -SqlInstance "SQL01" -Database "MyDB" -NewOwner "domain\admin"
Change owner for multiple databases with -WhatIf
Set-sqmDatabaseOwner -SqlInstance "SQL01" -Database "Prod*" -NewOwner "sqlsvc" -WhatIf