# Test for installed VPN clients
[version]$MyAppVer00 = Get-InstalledApplication 'Check Point VPN-1' | select 'DisplayVersion' -expand 'DisplayVersion'
[version]$MyAppVer01 = Get-InstalledApplication 'Check Point VPN' -Exact | select 'DisplayVersion' -expand 'DisplayVersion'
# Remove VPN Clients
If ($MyAppVer01 -ne $null){
Write-Log -Text 'Removing Check Point VPN...' -LogType 'Legacy'
Remove-MSIApplications -Name 'Check Point VPN' -Exact
}
If ($MyAppVer00 -ne $null){
Write-Log -Text 'Removing Check Point VPN-1...' -LogType 'Legacy'
Remove-MSIApplications -Name 'Check Point VPN-1'
Restart-Computer -Force
}
[version]$MyAppVer00 = Get-InstalledApplication 'Check Point VPN-1' | select 'DisplayVersion' -expand 'DisplayVersion'
[version]$MyAppVer01 = Get-InstalledApplication 'Check Point VPN' -Exact | select 'DisplayVersion' -expand 'DisplayVersion'
If ($MyAppVer00 -eq $null -and $MyAppVer01 -eq $null){
Write-Log -Text 'Installing CheckPointVPN_SYD1...' -LogType 'Legacy'
Execute-MSI -Action Install -Path 'CheckPointVPN.msi'
}
So we basically have two versions of Check Point VPN installed and I need to:
Remove Check Point VPN
Remove Check Point VPN-1
Reboot
Install Check Point VPN
I’m running this in our computer startup script and it seems to just skip the “Restart-Computer -Force” command and then hang on the install as it needs a reboot after the uninstall Check Point VPN-1.
If the target computer only has Check Point VPN-1, then the script works and reboots the computer.
What am I doing wrong?