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 SonicWall NetExtender using PowerShell.
How to Create a Custom Detection Script for SonicWall NetExtender
SonicWall NetExtender (File Detection Method)
- Install the version of SonicWall NetExtender you want to deploy on a test box or VM
- Check out the following posts for further details
- Open Windows PowerShell ISE by Right-Clicking on Windows PowerShell ISE and selecting Run as Administrator
- Copy the following code into the Windows PowerShell ISE
## Check for SonicWall NetExtender (File Detection Method) $NetExtenderExe = (Get-ChildItem -Path "C:\Program Files\SonicWall\SSL-VPN\NetExtenderr\NEGui.exe","C:\Program Files (x86)\SonicWall\SSL-VPN\NetExtender\NEGui.exe" -ErrorAction SilentlyContinue) $NetExtenderExe.FullName $NetExtenderPath = $($NetExtenderExe.FullName).Replace("C:\Program Files\","").Replace("C:\Program Files (x86)\","") $FileVersion = (Get-Item -Path "$($NetExtenderExe.FullName)" -ErrorAction SilentlyContinue).VersionInfo.FileVersion ## Create Text File with SonicWall NetExtender File Detection Method $FilePath = "C:\Windows\Temp\SonicWall_NetExtender_Detection_Method.txt" New-Item -Path "$FilePath" -Force Set-Content -Path "$FilePath" -Value "If([String](Get-Item -Path `"`$Env:ProgramFiles\$NetExtenderPath`",`"`${Env:ProgramFiles(x86)}\$NetExtenderPath`" -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 SonicWall NetExtender Detection Method script required to detect the current version of SonicWall NetExtender that is installed on the device you are running the script from.
Example:
If([String](Get-Item -Path "$Env:ProgramFiles\SonicWall\SSL-VPN\NetExtender\NEGui.exe","${Env:ProgramFiles(x86)}\SonicWall\SSL-VPN\NetExtender\NEGui.exe" -ErrorAction SilentlyContinue).VersionInfo.FileVersion -ge "10, 2, 324, 1"){ Write-Host "Installed" }
- Copy the SonicWall NetExtender Detection Method script content into the Custom Detection Rules (Script)
- Microsoft Endpoint Manager Configuration Manager (MEMCM / SCCM)
- Microsoft Intune
SonicWall NetExtender (Registry Detection Method)
- Install the version of SonicWall NetExtender you want to deploy on a test box or VM
- Check out the following posts for further details
- Open Windows PowerShell ISE by Right-Clicking on Windows PowerShell ISE and selecting Run as Administrator
- Copy the following code into the Windows PowerShell ISE
## Check for SonicWall NetExtender (Registry Detection Method) $NetExtender = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object {$_.DisplayName -like 'SonicWall NetExtender*' } | Select-Object -Property DisplayName, DisplayVersion, PSChildName $NetExtender.DisplayVersion $NetExtender.PSChildName ## Create Text File with SonicWall NetExtender Registry Detection Method $FilePath = "C:\Windows\Temp\SonicWall_NetExtender_Detection_Method.txt" New-Item -Path "$FilePath" -Force Set-Content -Path "$FilePath" -Value "If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$($NetExtender.PSChildName)','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$($NetExtender.PSChildName)' -Name DisplayVersion -ea SilentlyContinue) -ge '$($NetExtender.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 SonicWall NetExtender Detection Method script required to detect the current version of SonicWall NetExtender that is installed on the device you are running the script from.
Example:
If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF06A6A8-6B81-4A09-8223-789953972FFF}','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{EF06A6A8-6B81-4A09-8223-789953972FFF}' -Name DisplayVersion -ea SilentlyContinue) -ge '10.2.324') { Write-Host "Installed" }
- Copy the SonicWall NetExtender Detection Method script content into the Custom Detection Rules (Script)
- Microsoft Endpoint Manager Configuration Manager (MEMCM / SCCM)
- Microsoft Intune
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.