Install-sqmJdbcDriver Filesystem

Checks for an existing Microsoft JDBC Driver for SQL Server and, if absent, installs it from the source path — either via the Microsoft self-extractor (sqljdbc*.exe) or by directly copying the mssql-jdbc*.jar file. Optionally extends the system CLASSPATH environment variable.

Execution Flow

START Test-sqmDriverInstalled -DriverType JDBC Status=AlreadyInstalled; return Test-Path $SourcePath Status=Error; return Search $SourcePath: Get-ChildItem -Filter 'mssql-jdbc*.jar' -Recurse → $jarFile (newest first) AND: Get-ChildItem -Filter 'sqljdbc*.exe' → $exeFile (newest first) $exeFile found? Start-Process $exeFile /quiet /passive ExitCode ≠0 → Status=Error; return $jarFile found? Status=Error; return mkdir -Force $DestinationPath; Copy-Item $jarFile.FullName → $destJar Version from filename: mssql-jdbc-(\d+\.\d+\.\d+) regex match if -UpdateClassPath: [Environment]::GetEnvironmentVariable('CLASSPATH','Machine') → append $DestinationPath Return [PSCustomObject] { Status, Version, Path, Message } DONE

Synopsis

Searches $SourcePath for either a Microsoft self-extractor (sqljdbc*.exe) or a JAR file (mssql-jdbc*.jar). When an EXE is found it takes priority and is run silently. When only a JAR is found, it is copied to $DestinationPath (created if necessary) and version is parsed from the filename regex mssql-jdbc-(\d+\.\d+\.\d+). The -UpdateClassPath flag appends the destination directory to the system CLASSPATH machine environment variable if not already present.

No dbatools required. Requires local administrator rights. Default destination: C:\Program Files\Microsoft JDBC Driver for SQL Server. Uses Test-sqmDriverInstalled -DriverType JDBC for both pre-check and (after EXE install) post-install verification.

Syntax

Install-sqmJdbcDriver
    -SourcePath <String>                      # required
    [-DestinationPath <String>]               # default: C:\Program Files\Microsoft JDBC Driver for SQL Server
    [-UpdateClassPath <Bool>]                 # default $false

Parameters

ParameterTypeDefaultDescription
-SourcePathStringRequired. Directory or direct path to the JDBC installer or JAR file.
-DestinationPathStringC:\Program Files\Microsoft JDBC Driver for SQL ServerTarget directory for the JAR file (JAR-copy path only; ignored when an EXE installer is used).
-UpdateClassPathBool$falseWhen $true, appends $DestinationPath to the system CLASSPATH machine environment variable if not already present.

Return Value

PropertyDescription
StatusAlreadyInstalled — driver detected before install; Installed — successfully installed; Error — failure at any step.
VersionVersion string parsed from JAR filename or from Test-sqmDriverInstalled after EXE install.
PathPath to the installed JAR file or driver location.
MessageHuman-readable status description.

Examples

# Install from network share (auto-detect EXE or JAR)
Install-sqmJdbcDriver -SourcePath '\\srv\Treiber\JDBC'

# Install JAR and update CLASSPATH
Install-sqmJdbcDriver -SourcePath 'C:\Downloads\jdbc' -UpdateClassPath $true

# Custom destination path
Install-sqmJdbcDriver -SourcePath '\\srv\JDBC' -DestinationPath 'D:\Drivers\JDBC'