Automated App Packaging – FileZilla Client

There are a ton of different ways to help automate third-party patching for SCCM, community tools, vendor etc which can help save time. This example is a pretty basic powershell script that you can use for the FileZilla Client which should also be helpful if you want to adapt it to another application.

This script will go out to FileZilla’s page, download the latest EXE, check the version, compare it to the existing version, create an application if it is a new version, distribute the content to your Distribution Points and email you to let you know there is a new version available for testing.

The script assumes a few things that you can change-

  • You have FileZilla icon picture for the app catalog in your package source named FileZilla.png
  • You want the 64-bit Client
  • You have a FileZilla folder under applications in the console you want this moved to

Thanks to Mark Godfrey who provided the base for this script.

I have also added another script for to help automate Firefox that you can find here-

# Create Configuration Manager Application & Deployment Type for FileZilla

#Email Addresses for notifications of new version
$email = "YourEmail@address.com"
$SCCMemail = "SCCMServer@mydomain.com"

#Distribution point group to distribute content to
$DPGroup = "All Distribution Points"

#AppPath
$AppPath = "\\yourpackagesource"

#Get Download info
#Parse Landing Page
$HTML = Invoke-WebRequest -UseBasicParsing -URI "https://filezilla-project.org/download.php?show_all=1"
$url = $HTML.Links | Where-Object {$_.href -like "*win64-setup.exe*"} | select -ExpandProperty HREF | Out-String
$shorturl = $url.Substring(0, $url.IndexOf('download'))

#Download File and get version
$filename = "FilezillaClientx64.exe"
Invoke-WebRequest -Uri $shorturl -OutFile "$apppath\$filename"
$InstallFile = Get-Item -Path $AppPath\$filename
$version = (get-item "$InstallFile").versioninfo.fileversion

# New Version?
$folders = Get-ChildItem $AppPath | select -ExpandProperty Name
If($folders -eq $version){$NewVer = $false}else{$NewVer = $true}

If($NewVer -eq $false){exit}
else{
    
    # Create Folder and Copy Template w/ MSI
    $NewFolder = New-Item -Path $AppPath\$($version) -ItemType Directory
    Copy-Item -Path $AppPath\$FileName -Destination $NewFolder -Force

    # Set Application Name
    $ApplicationName = "FileZilla $Version"
        
    # Import CM Module
    Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")
    
    # Get CM Site Information
    $sitecode = Get-PSDrive -PSProvider CMSite | select -ExpandProperty Name

    # Detection Method
    $DetectProperties = @{

        FileName = 'filezilla.exe';

        Path = '%ProgramFiles%\FileZilla FTP Client\';

        Is64Bit = $True;

        PropertyType = 'Version';

        ExpectedValue = $Version;

        ExpressionOperator = 'GreaterEquals'

        Value = $True

    }

    $DetectScript = New-CMDetectionClauseFile @DetectProperties
    

    # Set Vars
    $IconFile = "$AppPath\FileZilla.png"
    $ContentLocation = $NewFolder.FullName
    $InstallProg = "FileZilla.exe /S user=all"
    $UninstallProg = '"%Programfiles%\FileZilla FTP Client\Uninstall.exe" /S'
    $Publisher = 'FileZilla'
    $CatalogDescription = "FileZilla Client"

    # Change Location to PSDrive
    Set-Location $sitecode":"

    # Create CM Application
    New-CMApplication -Name "$ApplicationName" -Publisher "$Publisher" -SoftwareVersion "$ProductVersion" -LocalizedApplicationName "$ApplicationName" -LocalizedApplicationDescription "$CatalogDescription" -IconLocationFile "$IconFile" -AutoInstall $True
    
    # Create CM Deployment Type
    Add-CMScriptDeploymentType -ApplicationName $ApplicationName -DeploymentTypeName $ApplicationName -ContentLocation "$ContentLocation" -InstallCommand $InstallProg -UninstallCommand $UninstallProg -AddDetectionClause ($detectscript) -InstallationBehaviorType InstallForSystem -LogonRequirementType WhetherOrNotUserLoggedOn -InstallationProgramVisibility Hidden -MaximumAllowedRunTimeMins '30' -EstimatedInstallationTimeMins '15'
            
    # Move Application to Desired Folder
    $Application = Get-CMApplication -Name $ApplicationName
    Move-CMObject -FolderPath $SiteCode":\Application\FileZilla" -InputObject $Application

    # Distribute Content
    Start-CMContentDistribution -ApplicationName $ApplicationName -DistributionPointGroupName "$DPGroup"

    # Send Email Notification
    Send-MailMessage -SmtpServer smtp.vitalimages.com -From $SCCMemail -To $email -Subject "New SCCM Application Created for $ApplicationName" -Body "$ApplicationName script has finished processing. It is ready for testing/deployments."

    }

Leave a Reply

Your email address will not be published. Required fields are marked *