Create a Custom Detection Script for ClickShare (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 ClickShare using PowerShell.

How to Create a Custom Detection Script for ClickShare

ClickShare (File Detection Method)

## Check for ClickShare (File Detection Method)
$ClickShareExe = (Get-ChildItem -Path "C:\ClickShareApp\ClickShare\clickshare_native.exe" -ErrorAction SilentlyContinue)
$ClickShareExe.FullName
$ClickSharePath = $($ClickShareExe.FullName).Replace("C:\","")
$FileVersion = (Get-Item -Path "$($ClickShareExe.FullName)" -ErrorAction SilentlyContinue).VersionInfo.FileVersion

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

Example:

If([String](Get-Item -Path "$Env:HomeDrive\ClickShareApp\ClickShare\clickshare_native.exe" -ErrorAction SilentlyContinue).VersionInfo.FileVersion -ge "4.22.0.13"){
Write-Host "Installed"
}

ClickShare (Registry Detection Method)

## Check for ClickShare (Registry Detection Method)
$ClickShare = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object {$_.DisplayName -like 'ClickShare*' -and $_.DisplayName -notlike 'ClickShare Extension Pack*' } | Select-Object -Property DisplayName, DisplayVersion, PSChildName
$ClickShare.DisplayVersion
$ClickShare.PSChildName

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

Example:

If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AA339187-2378-4980-961A-5018550483A9}','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AA339187-2378-4980-961A-5018550483A9}' -Name DisplayVersion -ea SilentlyContinue) -ge '4.22.0.13') {
Write-Host "Installed"
}

ClickShare Extension Pack (Registry Detection Method)

## Check for ClickShare Extension Pack (Registry Detection Method)
$ClickShareExt = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object {$_.DisplayName -like 'ClickShare Extension Pack*' } | Select-Object -Property DisplayName, DisplayVersion, PSChildName
$ClickShareExt.DisplayVersion
$ClickShareExt.PSChildName

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

Example:

If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5AC12BB5-967E-40D1-A929-F3A0B251772D}','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{5AC12BB5-967E-40D1-A929-F3A0B251772D}' -Name DisplayVersion -ea SilentlyContinue) -ge '1.2.0.6') {
Write-Host "Installed"
}

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.