Create a Custom Detection Script for DB Browser for SQLite (PowerShell)

Microsoft Endpoint Manager Configuration Manager (MEMCM / SCCM) and Microsoft Intune use Detection Rules to determine the presence of Applications & Win32 Apps. The detection rules ensure that application installations only begin to run if the application is not already installed on the device. This article will serve as an informative guide and give you a clear understanding of how to create an updated custom detection script for each new version of DB Browser for SQLite using PowerShell.

How to Create a Custom Detection Script for DB Browser for SQLite

DB Browser for SQLite (File Detection Method)

## Check for DB Browser for SQLite (File Detection Method)
$SQLiteBrowserExe = (Get-ChildItem -Path "C:\Program Files\DB Browser for SQLite\DB Browser for SQLite.exe","C:\Program Files (x86)\DB Browser for SQLite\DB Browser for SQLite.exe" -ErrorAction SilentlyContinue)
$SQLiteBrowserExe.FullName
$SQLiteBrowserPath = $($SQLiteBrowserExe.FullName).Replace("C:\Program Files\","").Replace("C:\Program Files (x86)\","")
$FileVersion = (Get-Item -Path "$($SQLiteBrowserExe.FullName)" -ErrorAction SilentlyContinue).VersionInfo.FileVersion

## Create Text File with DB Browser for SQLite File Detection Method
$FilePath = "C:\Windows\Temp\DB_Browser_for_SQLite_Detection_Method.txt"
New-Item -Path "$FilePath" -Force
Set-Content -Path "$FilePath" -Value "If([String](Get-Item -Path `"`$Env:ProgramFiles\$SQLiteBrowserPath`",`"`${Env:ProgramFiles(x86)}\$SQLiteBrowserPath`" -ErrorAction SilentlyContinue).VersionInfo.FileVersion -ge `"$FileVersion`"){"
Add-Content -Path "$FilePath" -Value "Write-Host `"Installed`""
Add-Content -Path "$FilePath" -Value "Exit 0"
Add-Content -Path "$FilePath" -Value "}"
Add-Content -Path "$FilePath" -Value "else {"
Add-Content -Path "$FilePath" -Value "Exit 1"
Add-Content -Path "$FilePath" -Value "}"
Invoke-Item $FilePath
  • Click Run Script (F5)
  • A text file will open with the DB Browser for SQLite Detection Method script required to detect the current version of DB Browser for SQLite that is installed on the device you are running the script from.

Example:

If([String](Get-Item -Path "$Env:ProgramFiles\DB Browser for SQLite\DB Browser for SQLite.exe","${Env:ProgramFiles(x86)}\DB Browser for SQLite\DB Browser for SQLite.exe" -ErrorAction SilentlyContinue).VersionInfo.FileVersion -ge "3.12.2.20210502"){
Write-Host "Installed"
Exit 0
}
else {
Exit 1
}

DB Browser for SQLite (Registry Detection Method)

## Check for DB Browser for SQLite (Registry Detection Method)
$SQLiteBrowser = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object {$_.DisplayName -match 'DB Browser for SQLite' } | Select-Object -Property DisplayName, DisplayVersion, PSChildName
$SQLiteBrowser.DisplayVersion
$SQLiteBrowser.PSChildName

## Create Text File with DB Browser for SQLite Registry Detection Method
$FilePath = "C:\Windows\Temp\DB_Browser_for_SQLite_Detection_Method.txt"
New-Item -Path "$FilePath" -Force
Set-Content -Path "$FilePath" -Value "If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$($SQLiteBrowser.PSChildName)','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$($SQLiteBrowser.PSChildName)' -Name DisplayVersion -ea SilentlyContinue) -ge '$($SQLiteBrowser.DisplayVersion)') {"
Add-Content -Path "$FilePath" -Value "Write-Host `"Installed`""
Add-Content -Path "$FilePath" -Value "Exit 0"
Add-Content -Path "$FilePath" -Value "}"
Add-Content -Path "$FilePath" -Value "else {"
Add-Content -Path "$FilePath" -Value "Exit 1"
Add-Content -Path "$FilePath" -Value "}"
Invoke-Item $FilePath
  • Click Run Script (F5)
  • A text file will open with the DB Browser for SQLite Detection Method script required to detect the current version of DB Browser for SQLite that is installed on the device you are running the script from.

Example:

If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DE0EB075-3F05-4A25-8075-5BBAE6D38BEC}','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{DE0EB075-3F05-4A25-8075-5BBAE6D38BEC}' -Name DisplayVersion -ea SilentlyContinue) -ge '3.12.2') {
Write-Host "Installed"
Exit 0
}
else {
Exit 1
}

Always make sure to test everything in a development environment prior to implementing anything into production. The information in this article is provided “As Is” without warranty of any kind.