Enable-sqmMonitoringAccess
Security
sqmSQLTool v1.8.2+ · Setup
✓ -WhatIf supported ⚠ ConfirmImpact: High
InstalledInstances and performs the full setup on each one:
Per instance: Create/ensure a server role with
VIEW SERVER STATE, VIEW ANY DATABASE, VIEW ANY DEFINITION, ALTER TRACE, and CONNECT ANY DATABASE; create/ensure the Windows login and add it to that role; create/ensure a database role in master and msdb with the matching database user and granular GRANT permissions (system views, xp_loginconfig, msdb proxy stored procs).
If
-PolicyName is provided (or configured via Get-sqmConfig), the policy is disabled before setup and re-enabled afterwards — even on error. A log file is written to -OutputPath on completion.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -ComputerName | string | Optional | $env:COMPUTERNAME | Target computer. All SQL Server instances on this computer are configured. |
| -MonitoringUser | string | Optional* | Get-sqmConfig 'DefaultMonitoringUser' | Windows login of the monitoring account (e.g. DOMAIN\SvcMonitoring). Required if not set in module config. |
| -ServerRoleName | string | Optional | MonitoringRole | Name of the server-level role to create. |
| -DatabaseRoleName | string | Optional | MonitoringDbRole | Name of the database role created in master and msdb. |
| -PolicyName | string | Optional | Get-sqmConfig 'DefaultPolicy' | SQL Server Policy to disable before and re-enable after setup. Omit (or leave unconfigured) to skip policy management. |
| -OutputPath | string | Optional | C:\System\WinSrvLog\MSSQL | Directory for the log file. |
| -SqlCredential | PSCredential | Optional | — | SQL credential for all instance connections. |
| -ContinueOnError | switch | Switch | $false | Log the error and continue to the next instance instead of aborting. |
| -EnableException | switch | Switch | $false | Throw immediately on error. |
| -WhatIf / -Confirm | switch | Optional | — | ShouldProcess (ConfirmImpact: High) gates the per-instance setup. -WhatIf returns Status='WhatIf' per instance. |
Execution Flow
Examples
Set up monitoring account on the local computer
Enable-sqmMonitoringAccess -MonitoringUser "CORP\SvcMonitoring"
Set up on a remote server with custom role names and policy management
Enable-sqmMonitoringAccess `
-ComputerName "SQL01" `
-MonitoringUser "CORP\SvcMonitoring" `
-ServerRoleName "MonRole" `
-DatabaseRoleName "MonDbRole" `
-PolicyName "Enforce Password Policy" `
-ContinueOnError