Community Script Share - Kofax Power PDF Advanced

There has been some great community script shares occurring on the MSPGeek discord/slack channel by the community, however these tend to get lost over there in the endless scroll.

Please note, there is no warranty or support inferred or supplied by the ImmyBot team with community shared scripts.

Remember use community created scripts at your own risk, do not test in production.
Recommend reviewing and running thorough tests in a lab environment before using in a production environment.

To help encourage the community to share scripts on the community site I’ll start with sharing how I was able to get Kofax PDF to work with Immy.
Kofax PDF is not in the global repo because they lock their installers behind a “pay wall”, as such the ImmyBot team is unable to obtain the required installer files to manage and support this software being in global.

I’ve attempted to go more in depth with this write up rather than just sharing a couple of scripts.
While there will be some in the community who don’t need this in-depth details, I feel like this could help as a general starting point for those looking to create their own software.
Any feedback that might assist making some of these steps more clear if they are not already is greatly appreciated.

In your ImmyBot instance go to Library > Software > New

Enter a Software Name such as Kofax Power PDF Advanced.
Upload an icon here if you wish to do so.

Licensing select required as Kofax requires a license key to install and be activated and for the license type select Key, as this will be required if you want to install Kofax licensed with the key provided by the vendor.
Enter notes in the description for the key if you wish to do so, such as a link to an ITGlue where the license keys for Kofax can be obtained for example.

For version detection as Kofax doesn’t use a valid semantic version in add/remove programs, we will need to select custom detection script and then click on new and it will open the script editor to create a new script.

Copy the below script into the script editor in Immy that opens for the custom detection script after you clicked on new.

$ProductCode = Detect-Software -RegexSoftwareSearchString 'Kofax Power PDF' | Select -First 1 | Select -ExpandProperty ProductCode
$RegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{$ProductCode}"
$VersionMajor = Get-WindowsRegistryValue -Path $RegKey -Name "VersionMajor" 
$VersionMinor = Get-WindowsRegistryValue -Path $RegKey -Name "VersionMinor" 
$DisplayVersion = Get-WindowsRegistryValue -Path $RegKey -Name "DisplayVersion" 
$BaseVersion = "$VersionMajor.$VersionMinor"
$BuildFound = $DisplayVersion -match '\d{5}'
if($BuildFound) {
    $Build = $matches[0]
}
else{
    return $null
}
if($Build) {
    return "$BaseVersion.$Build"
}
return $BaseVersion

For the installation script, click on new click on new and it will open the script editor to create a new script.

Copy the below script into the script editor in Immy that opens for the installation script after you clicked on new.

[System.Version]$SoftwareVersion = $DisplayVersion
if($SoftwareVersion.Major -lt 5) {
$Arguments = @"
/c msiexec /i "$InstallerFile" /qn /l*v "$InstallerLogFile" ISX_SERIALNUM=$LicenseValue UPGLEGACY="1" UPGNOQUESTION="1"
"@
}
else {
#https://knowledge.kofax.com/MFD_Productivity/Power_PDF/Install_Uninstall/Power_PDF_v5_30_days_grace_period_appears_when_performing_an_command_line_silent_install_using_the_legacy_serial_number
$Arguments = @"
/c msiexec /i "$InstallerFile" /qn /l*v "$InstallerLogFile" ACTMODE="SN" ISX_SERIALNUM=$LicenseValue UPGLEGACY="1" UPGNOQUESTION="1"
"@
}

Write-Host "InstallerLogFile: $InstallerLogFile"
$Process = Start-Process -Wait cmd -ArgumentList $Arguments -Passthru
Write-Host "Exit Code: $($Process.ExitCode)";
switch ($Process.ExitCode)
{
    0 { Write-Host "Success" }
    3010 { Write-Host "Success. Reboot required to complete installation" }
    1641 { Write-Host "Success. Installer has initiated a reboot" }
    default {
        Write-Host "Exit code does not indicate success"
        Get-Content $InstallerLogFile -ErrorAction SilentlyContinue | select -Last 50
    }
}

For the configuration task, click on new

In the parameters add 3 parameters as below.

Scroll down past the parameters while still in the configuration task and select the “Configure Default PDF Handler” script that is in global.

Under versions click on new and upload the base Kofax installer. The base version of Kofax is required before you can install their patch versions.
Zip the installer up which typically will look like this:


When on the upload version page of Immy you will select package type of Zip file and define where the installer executable path is within the zip.

System64\Kofax Power PDF Advanced.msi is the path within the zip where the MSI installer can be found, this will be the installer file that is passed to $InstallerFile variable during a session and used in the install script as $InstallerFile Scripting Guide | $InstallerFile

Enter the version string for the base version as 5.0.22223.
This version was obtain by manually installed the base version.

On the software page you will now upload another version which is their patches, from memory Kofax calls this a “Fix Pack” and require the base version to be installed before the fix pack can be installed, but also any version running with an already updated fix pack can also be patched.
Follow the same steps to upload an installer again.
The fix pack is already and MSI that doesn’t need to be zipped, but due to the file size I prefer to zip up the MSI first.
If you zip the MSI first, do the same as before with selecting Zip file as the package type and the installer path would simply be the MSI name assuming it is at the root of the zip file and not in any subfolders.

The version string you enter for the fix pack depends on what fix pack you have. You may need to try installing this on an endpoint first to obtain the version.
I believe the fix pack 9 was 5.0.23269.

While still on the version page for the fix pack you just uploaded, as it requires the base to be installed first we want to select a depends on version and select the base version.


Having the base version selected as a depends on means if there is no existing base install, ImmyBot will first install the base version required, and once installed, then install the path version, if the base version is already installed, it will only need to install the patch.

I’m sure there might be some improvements that could be made with the detection / install scripts, but these worked when I had access to Kofax installers at one point.
I don’t recall that I ever had a need to get an uninstall script going, so maybe someone in the community who has Kofax and a need for an uninstall script might be able to share a method for uninstall.

Hope this may help anyone who needs a Kofax software deployment or even a useful general guide on creating your own software deployment!