Execution Flow
Synopsis
Reads or writes the sqmSQLTool monitoring registry key HKLM:\System\dtcSoftware\sqmSQLTool on one or more computers. Controls SQL monitoring level (None/Standard/Full), free-space monitoring variant (Standard/Cluster for AlwaysOn), and TSM backup monitoring (0/1). With -AutoDetectSQLFreeSpaceVersion, the function automatically checks for AlwaysOn AGs via dbatools and sets the value accordingly. Remote computers are accessed via Invoke-Command (WinRM).
The registry key is created automatically if it does not exist during a Set operation. Read operations never create the key.
Syntax
Invoke-sqmMonitoringKey [-ComputerName <String[]>] # pipeline-capable [-Operation <Get|Set>] [-SQL <None|Standard|Full>] [-SQLFreeSpaceVersion <Standard|Cluster>] [-TSM <0|1>] [-RegistryBase <String>] [-AutoDetectSQLFreeSpaceVersion] [-Credential <PSCredential>] [-ContinueOnError] [-EnableException]
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| -ComputerName | String[] | $env:COMPUTERNAME | One or more target computers. Accepts pipeline input. |
| -Operation | String | Get | Get: read current values. Set: write the supplied values. |
| -SQL | String | — | SQL monitoring level: None (DWORD 0), Standard (1), Full (2). |
| -SQLFreeSpaceVersion | String | — | Standard (standalone instance) or Cluster (AlwaysOn AG). |
| -TSM | Int | — | TSM backup monitoring: 0 = inactive, 1 = active. |
| -RegistryBase | String | System | Registry hive path base under HKLM (e.g. System, Software). |
| -AutoDetectSQLFreeSpaceVersion | Switch | false | When set with -Operation Set, auto-detect via Get-DbaAvailabilityGroup and set Cluster or Standard. |
| -Credential | PSCredential | — | Windows credential for WinRM access to remote computers. |
| -ContinueOnError | Switch | false | Continue with the next computer on error instead of stopping. |
| -EnableException | Switch | false | Throw terminating exceptions (overrides ContinueOnError). |
Return Value
Array of [PSCustomObject] — one entry per computer:
| Property | Description |
|---|---|
| ComputerName | Target computer name. |
| RegistryPath | Full registry path that was read/written. |
| SQL | Raw DWORD value (0/1/2) or null if not set. |
| SQL_Description | Decoded: NoMonitoring / ServiceMonitoring / FullMonitoring. |
| SQLFreeSpaceVersion | String value: Standard or Cluster. |
| TSM | Raw value 0/1 or null if not set. |
| TSM_Description | Inactive or Active. |
| Status | OK / Updated / Created / KeyNotFound / WhatIfSkipped / Failed. |
| Message | Human-readable status message. |
Examples
# Read monitoring key on local computer Invoke-sqmMonitoringKey # Set Standard SQL monitoring with TSM active, auto-detect AG topology Invoke-sqmMonitoringKey -Operation Set -SQL Standard -TSM 1 -AutoDetectSQLFreeSpaceVersion # Set Full monitoring on multiple servers via pipeline "SQL01","SQL02","SQL03" | Invoke-sqmMonitoringKey -Operation Set -SQL Full -TSM 1 # Read from a remote server with explicit credential Invoke-sqmMonitoringKey -ComputerName "REMOTEDB" -Credential (Get-Credential)
Registry Value Mapping
| Value Name | Type | Values | Decoded As |
|---|---|---|---|
| SQL | DWORD | 0 / 1 / 2 | NoMonitoring / ServiceMonitoring / FullMonitoring |
| SQLFreeSpaceVersion | String | Standard / Cluster | Standalone instance / AlwaysOn AG |
| TSM | DWORD | 0 / 1 | Inactive / Active |