Configuration

Invoke-sqmSplunkConfiguration

Configures the Splunk Universal Forwarder on SQL Server hosts. Detects all SQL instances via registry, sets machine-wide MSSQL{n}_Log environment variables, and manages the SplunkForwarder service — locally or remotely via AD OU or explicit server list.

Module: sqmSQLTool
dbatools: No
ShouldProcess: No
Output: PSCustomObject

Execution Flow

START Resolve LogPath (config / default) ParameterSet? Remote / List / Local Remote AD OU Get-ADComputer List Explicit list / text file Invoke-Command (WinRM) → _sqmSplunk_LocalCore Local _sqmSplunk_LocalCore Mode=Set? Admin required Not admin abort + warn HKLM:\...\Instance Names\SQL → instance list foreach instance Set MSSQL{n}_Log = ErrorLog path (skip if already set; Mode=Test → read only) SplunkForwarder: Start / Restart service Check MSSQL*_Log env vars → IsConfigured DONE
Existing environment variables are never overwritten — only missing MSSQL{n}_Log entries are added. Mode=Test is read-only and never writes anything. Remote execution requires WinRM on target servers; AD OU mode requires the ActiveDirectory module (auto-installed via Install-sqmAdModule).

Parameters

ParameterTypeRequiredParameterSetDescription
-ModeStringOptionalAllSet (default) — write env vars + manage service. Test — read-only check.
-RemoteSwitchOptionalRemoteExecute via WinRM on servers discovered from Active Directory OU.
-SearchOUStringOptionalRemoteAD OU distinguished name or simple name. Default: OUServDatabase.
-ComputerListString[]OptionalListExplicit server names or path to a text file (lines starting with # are comments).
-CredentialPSCredentialOptionalRemote / ListCredentials for AD queries and WinRM remoting.
-LogPathStringOptionalAllLog directory. Defaults to Get-sqmConfig 'LogPath' or %ProgramData%\sqmSQLTool\Logs.
-LogCallbackScriptBlockOptionalAllGUI logging callback. If omitted, writes to Write-Host.

Return Value

Local mode: PSCustomObject with ComputerName, Mode, Status, Message, IsConfigured, ServiceStatus. Remote/List modes: PSCustomObject[] with Computer, Status, Fehler per server.

Examples

Example 1 — Local Set (default)

Invoke-sqmSplunkConfiguration

Example 2 — Test mode (read-only)

Invoke-sqmSplunkConfiguration -Mode Test

Example 3 — Remote AD OU

Invoke-sqmSplunkConfiguration -Remote -SearchOU "OU=DB-Server,DC=contoso,DC=com"

Example 4 — Explicit server list

Invoke-sqmSplunkConfiguration -ComputerList "SRV-SQL01","SRV-SQL02"

Example 5 — From text file, test mode

Invoke-sqmSplunkConfiguration -ComputerList "C:\Lists\db-server.txt" -Mode Test