Checks for an existing Microsoft ODBC Driver for SQL Server and, if absent, runs the silent installer (msodbcsql*.msi or msodbcsql*.exe) from the specified source path. Accepts ExitCode 3010 (reboot required) as success. Returns a status object with AlreadyInstalled, Installed, or Error.
Execution Flow
Synopsis
Uses Test-sqmDriverInstalled -DriverType ODBC for both the pre-check and post-install verification. When -DriverName is provided it is forwarded to the pre-check for a more specific match. When $SourcePath is a directory, the newest matching msodbcsql*.msi or msodbcsql*.exe is selected via descending filename sort. MSI installs pass IACCEPTMSODBCSQLLICENSETERMS=YES for fully unattended execution. ExitCode 3010 (reboot required) is treated as success with a hint appended to the message.
No dbatools required. Requires local administrator rights. No CLASSPATH or registry changes are needed — the MSI/EXE registers the ODBC driver automatically in HKLM\SOFTWARE\ODBC\ODBCINST.INI.
Syntax
Install-sqmOdbcDriver-SourcePath <String> # required; directory or direct path to installer
[-DriverName <String>] # optional: specific driver name for pre-check
Parameters
Parameter
Type
Default
Description
-SourcePath
String
—
Required. Directory containing msodbcsql*.msi or *.exe, or direct path to an installer file.
-DriverName
String
—
Optional driver name filter for Test-sqmDriverInstalled. When omitted, the newest Microsoft SQL ODBC driver is auto-detected.
Return Value
Property
Description
Status
AlreadyInstalled — driver detected before install; Installed — successfully installed; Error — failure at any step.
Version
Detected driver version from Test-sqmDriverInstalled post-install, or $null.
Path
Driver path as returned by Test-sqmDriverInstalled.
Message
Human-readable status; includes (Neustart empfohlen) hint when ExitCode was 3010.
Examples
# Install from network share directoryInstall-sqmOdbcDriver-SourcePath'\\srv\Treiber\ODBC'# Install from direct MSI fileInstall-sqmOdbcDriver-SourcePath'C:\Setup\msodbcsql18.msi'# Install and check for specific driver versionInstall-sqmOdbcDriver-SourcePath'\\srv\ODBC'-DriverName'ODBC Driver 18 for SQL Server'# Check result$r = Install-sqmOdbcDriver-SourcePath'\\srv\ODBC'Write-Host"$($r.Status) v$($r.Version): $($r.Message)"