Skip to content

Instantly share code, notes, and snippets.

@mbourgon
Last active May 15, 2024 13:05
Show Gist options
  • Save mbourgon/05c75cda141745e4244bbe876cba5c10 to your computer and use it in GitHub Desktop.
Save mbourgon/05c75cda141745e4244bbe876cba5c10 to your computer and use it in GitHub Desktop.
odbc driver file versions - find which version of all the drivers are installed.
#the property "DriverODBCVer" is which version of *ODBC* it supports. We have to get the file info.
#https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/how-to-correctly-check-file-versions-with-powershell/ba-p/257642
$odbc= get-odbcdriver|where {$_.name -match "sql server"}
$flat = foreach ($odbclist in $odbc){
foreach($Property in ($odbclist.attribute)){
$driverfilename = $property.driver -replace "%WINDIR%", "C:\windows\"
$driverversion = ((get-item $driverfilename).VersionInfo |select -expand Fileversion)
[pscustomobject]@{
name = ($odbclist.name)
Property = $Property.driver
#Value = $Property.DriverODBCVer
Filever = $driverversion
}}
}
$flat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment