PowerShell Uninstall Automation

I have authored the PowerShell Uninstall script.  It gives the ability for IT Operations / ConfigMgr Admins to uninstall multiple versions of a particular software with one process.

Does your organization struggle when trying to cleanup software when standardizing on a application version? I.E. Oracle Java, Adobe Flash, RightFax, IBM products, etc…  Not all the versions you have are in ConfigMgr / SCCM or not in the application model?  If the answer is yes, the PowerShell Uninstall script is for you.

The PowerShell Uninstall script takes inputs from a CSV file.  Using the delimiter of “^”, don’t worry I have included a Excel file to build your CSV.

Since by nature when uninstalling legacy software there maybe pre-or post- process you must run. The PowerShell Uninstall script has functions to call a PowerShell script before or after the uninstall logic.

The PowerShell Uninstall script also includes a Boolean to  create the script as an ConfigMgr / SCCM Application.  In which you can attach to other programs for requirements.

To detect the PowerShell Uninstall script, have ConfigMgr / SCCM check existence of “%SystemDrive%\Program Files\Pomeroy\AppName”.  It will be an empty directory.  For the uninstall just use the command “rmdir /Q /S %SystemDrive%\Program Files\Pomeroy\AppName”

PowerShell Uninstall Script Help:

<#    
    .SYNOPSIS
    ==================================================
     Created with:     SAPIEN Technologies
     Created on:       7/6/2015
     Created by:       Tim Knapp - PowerShell Uninstall
     Organization:     Pomeory
     Filename:         pomeroy.posh.uninstall.ps1
     Version:          1.15.7.1
     Web Site:         http://ITOpsReborn.com
    ==================================================
    .DESCRIPTION
        PowerShell Uninstall Script to automate the uninstall 
        of product codes complied in a text file
        Use the 'pomeroy.psoh.uninstaller.file.builder.vX 
        XXXXXXXX.xlsx' to build 
        the proper file. 
        You can use current direcotry syntax '.\' for 
        parameters that take  file paths for input.
        Script is written in PowerShell v2 Syntax.
        Will work out of box on Vista and later.
    .EXAMPLE
        pomeroy.posh.uninstall.ps1 -FilePath .\ProductCodes.txt
        -AppName "AppName" -SCCM true
        This Command will run the script in sccm detection 
        mode (SCCM APPLICATIONS)
    .EXAMPLE 
        pomeroy.posh.uninstall.ps1 -FilePath .\ProductCodes.txt 
        -AppName "AppName"
        This command will run the script in non-sccm detection 
        mode (SCCM PACKAGES)
    .EXAMPLE
        pomeroy.posh.uninstall.ps1 -FilePath .\Products.txt 
        -AppName "AppName" -PreProcess .\PreProcess.ps1
        This command will run the script in non-sccm 
        detection mode (SCCM PACKAGES)
        It will run the specified PowerShell script 
        before the uninstall logic runs
    .EXAMPLE
        pomeroy.posh.uninstall.ps1 -FilePath .\Products.txt 
        -AppName "AppName" -AfterProcess .\AfterProcess.ps1
        This command will run the script in non-sccm 
        detection mode (SCCM PACKAGES)
        It will run the specified PowerShell script 
        after the uninstall logic runs
    .EXAMPLE
        pomeroy.posh.uninstall.ps1 -FilePath .\Products.txt 
        -AppName "AppName" -SCCM True -PreProcess .\PreProcess.ps1
        -AfterProcess .\AfterProcess.ps1 
        This Command will run the script in sccm detection 
        mode (SCCM APPLICATIONS)
        It will run the specified PowerShell script before 
        the uninstall logic runs
        It will run the specified PowerShell script after 
        the uninstall logic runs
    .NOTES
        07/06/2015    1.15.7.1    Initial Release
#>

ConfigMgr Setup Configuration | Application :

ConfigMgr Application Source Directory:

PowerShell Uninstall Automation - ConfigMgr Source Directory

ConfigMgr Application | Deployment Type – General :

PowerShell Uninstall Automation - ConfigMgr App General

ConfigMgr Application Deployment Type – Content:

PowerShell Uninstall Automation - ConfigMgr App Content

ConfigMgr Application Deployment Type – Programs

Install:
powershell.exe -executionpolicy bypass -file .\pomeroy.posh.uninstall.ps1 -FilePath .\RightFaxCodes.txt -AppName “POSHRightFaxUninstall” -SCCM True -PreProcess .\RightFaxPreprocess.ps1

Uninstall:
RMDIR /S /Q “%ProgramFiles%\Pomeroy\POSHRightFaxUninstall”

PowerShell Uninstall Automation - ConfigMgr App Programs

ConfigMgr Application Deployment Type – Detection Method

PowerShell Uninstall Automation - ConfigMgr App Detection

PowerShell Uninstall Automation - ConfigMgr App Detection Rule

ConfigMgr Application Deployment Type – User Experience

PowerShell Uninstall Automation - ConfigMgr App User Experience

The sample files have been included in the download.

Download the files here:

4 thoughts on “PowerShell Uninstall Automation

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.