Checks for an existing IBM DB2 ODBC/CLI driver and, if absent, runs the silent installer from the specified source path. After installation, registers the driver via db2cli.exe -setup -registerall if needed. Returns a status object with AlreadyInstalled, Installed, or Error.
Execution Flow
Synopsis
Uses Test-sqmDriverInstalled -DriverType DB2 as both the pre-check and the post-install verification. When the source path is a directory, installers are ranked: db2_odbc_cli_64.exe (preferred) → db2_odbc_cli.exe → full DB2 client (db2client*.exe, setup.exe) → .msi. After EXE install, the function attempts to register the ODBC driver via db2cli.exe -setup -registerall at the standard IBM SQLLIB paths.
No dbatools required. Requires local administrator rights. ExitCode 3010 (reboot required) is treated as success. Uses internal _Log helper that wraps Invoke-sqmLogging with a try/catch so the function works even outside the full module context.
Syntax
Install-sqmDb2Driver-SourcePath <String> # required; directory or direct path to installer
Parameters
Parameter
Type
Default
Description
-SourcePath
String
—
Required. Path to the installer directory (e.g. \\srv\Driver\DB2) or directly to an installer file (e.g. C:\Downloads\db2_odbc_cli_64.exe).
Return Value
Property
Description
Status
AlreadyInstalled — driver detected before install; Installed — successfully installed; Error — failure at any step.
Version
Detected driver version string (from Test-sqmDriverInstalled), or $null.
Path
Detected driver or installation path.
Message
Human-readable status or error description.
Installer Priority (directory mode)
Priority
File Pattern
Type
0 (highest)
db2_odbc_cli_64.exe
IBM CLI Driver 64-bit
1
db2_odbc_cli.exe
IBM CLI Driver 32-bit
2
db2client*.exe
IBM DB2 Client
2
setup.exe
Full IBM installer
2
*.msi
MSI package
Examples
# Install from network share directoryInstall-sqmDb2Driver-SourcePath'\\srv\Treiber\DB2'# Install from explicit file pathInstall-sqmDb2Driver-SourcePath'C:\Downloads\db2_odbc_cli_64.exe'# Check result$r = Install-sqmDb2Driver-SourcePath'\\srv\Treiber\DB2'Write-Host"$($r.Status): $($r.Message)"