Commands / Uninstall-sqmOdbcDriver
Driver Install/Uninstall

Uninstall-sqmOdbcDriver

Finds the installed Microsoft ODBC Driver for SQL Server in the Windows uninstall registry (64-bit and WOW6432Node) and removes it silently via msiexec /x. Typically run right before installing a newer driver version.

Module: sqmSQLTool
Requires: Local Administrator
ShouldProcess: No
Output: PSCustomObject

Execution Flow

START Scan Uninstall registry (64-bit + WOW6432Node) for -DriverName pattern Entry found? Status = NotFound Resolve ProductCode (registry key name or parsed from UninstallString) ProductCode resolved? Status = Error msiexec /x <ProductCode> /quiet /norestart ExitCode? 0 / 1605 / 3010 / other 0 or 3010 → Status = Uninstalled 1605 → NotFound other → Error Return PSCustomObject (Status, Message) DONE
Exit code 1605 ("this action is only valid for products that are currently installed") is treated as NotFound, not an error, the driver simply wasn't there. Exit code 3010 means the uninstall succeeded but a reboot is recommended. Without -DriverName, the registry is scanned for the pattern Microsoft ODBC Driver \d+ for SQL Server and the highest version number found is removed.

Parameters

ParameterTypeRequiredDescription
-DriverNameStringOptionalSpecific driver display name to match. Default: wildcard pattern Microsoft ODBC Driver * for SQL Server (matches the highest installed version).

Return Value

Returns a single PSCustomObject with: Status (Uninstalled, NotFound, or Error), Message.

Examples

Example 1, Remove whichever ODBC driver version is installed

Uninstall-sqmOdbcDriver

Example 2, Target a specific driver version explicitly

Uninstall-sqmOdbcDriver -DriverName "Microsoft ODBC Driver 17 for SQL Server"

Example 3, Uninstall, then install the newer driver

Uninstall-sqmOdbcDriver
Install-sqmOdbcDriver