Install-sqmDb2Driver Filesystem

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

START Test-sqmDriverInstalled -DriverType DB2 Status=AlreadyInstalled; return Test-Path $SourcePath Status=Error; return Locate installer (directory or direct file) If PSIsContainer: Get-ChildItem -Include db2_odbc_cli_64.exe, db2_odbc_cli.exe, db2client*.exe, setup.exe, *.msi -Recurse Priority sort: db2_odbc_cli_64.exe (0) → db2_odbc_cli.exe (1) → others (2); Select-Object -First 1 Installer found? Status=Error; return Run installer: .msi → msiexec /i /quiet /norestart | .exe → Start-Process /silent -Wait -PassThru ExitCode 0 or 3010 (reboot) = success; other → Status=Error; return Post-install ODBC registration: search for db2cli.exe in C:\Program Files\IBM\SQLLIB\BIN\ (64-bit) and C:\Program Files (x86)\IBM\SQLLIB\BIN\; run: db2cli.exe -setup -registerall Test-sqmDriverInstalled -DriverType DB2 (post-install verify) → $check2.Version, $check2.Path Return [PSCustomObject] { Status, Version, Path, Message } DONE

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

ParameterTypeDefaultDescription
-SourcePathStringRequired. 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

PropertyDescription
StatusAlreadyInstalled — driver detected before install; Installed — successfully installed; Error — failure at any step.
VersionDetected driver version string (from Test-sqmDriverInstalled), or $null.
PathDetected driver or installation path.
MessageHuman-readable status or error description.

Installer Priority (directory mode)

PriorityFile PatternType
0 (highest)db2_odbc_cli_64.exeIBM CLI Driver 64-bit
1db2_odbc_cli.exeIBM CLI Driver 32-bit
2db2client*.exeIBM DB2 Client
2setup.exeFull IBM installer
2*.msiMSI package

Examples

# Install from network share directory
Install-sqmDb2Driver -SourcePath '\\srv\Treiber\DB2'

# Install from explicit file path
Install-sqmDb2Driver -SourcePath 'C:\Downloads\db2_odbc_cli_64.exe'

# Check result
$r = Install-sqmDb2Driver -SourcePath '\\srv\Treiber\DB2'
Write-Host "$($r.Status): $($r.Message)"