Wednesday, November 4, 2015

Uninstall Strings

Overview


As a software packager/patch manager, knowing how to uninstall software, and often, silently can be a nightmare. Most vendors will typically have an "Uninstall String" in the registry. This is the command used when you go to Programs and Features and click Uninstall, but those are not silent. You have to click through the uninstall wizard until it shows it is finished.

If the software was packaged as a Windows Installer package (.MSI), then adding silent switches is very simple because you use the default Windows Installer switches (typically /qn). Other packaging methods, unless the vendor has documented, it can be a guessing game (/s vs. /silent or /q vs. /quiet /u vs. /uninstall) and even then, a silent option may not even exist.

Because most software vendors create the Uninstall String in the registry, I can utilize SCCM 2012 to include this key in the Hardware Inventory (yes, Hardware, not Software). Older versions of SCCM require modification of a .MOF file, but 2012, you can add it from an existing machine. I will not go into the details of modifying the .MOF file as there are other articles out there that cover this.

For this blog, I'll be documenting the method of modifying the Hardware Inventory for SCCM 2012, then creating an SCCM (SSRS) Report where you can type in the name of the product and see if an Uninstall String exists and show that string the in the report.


Modify the Hardware Inventory - SCCM 2012


Depending on your company's configuration, you will want to modify the Client Settings that include Hardware Inventory. This is usually done with "Default Client Settings", but your environment may have several different setting profiles. Choose the one that is appropriate for your environment if Default Client Settings is not used.

In the System Center 2012 Configuration Manager Console (connected to your CAS, not a Primary), do the following:

01.  Click on Administration
02.  Click on Client Settings
03.  Right mouse click "Default Client Settings" and choose Properties


04.  Select Hardware Inventory, the click Set Classes...



05.  Scroll down to Installed Applications (64) (Win32Reg_AddRemovePrograms64) or Installed Applications (Win32Reg_AddRemovePrograms)
06.  If you do not see one or the other, they will need to be added. Skip to Step 08 below. Otherwise, expand both and make sure UninstallString is checked.




07.  If it is already checked, then you are already collecting the inventory and can move on to creating the report. Otherwise, check the box(es) and click OK.

Depending on how often you have Hardware Inventory scheduled to run, it can take a few days to get a good amount of data. Force a Hardware Inventory to run on a few machines to verify the data is being collected and create the report.

08.  To add Installed Applications (64) (Win32Reg_AddRemovePrograms64) or Installed Applications (Win32Reg_AddRemovePrograms), click the Add... button.

09.  Click the Connect... button and enter a machine name and credentials with admin rights (not needed if pulling from the machine running the console). Make sure the Recursive box is checked, then click Connect. This may take a minute or two to load.




10.  In the Search box, type Reg_Add. You should see Win32Reg_AddRemovePrograms and Win32Reg_AddRemovePrograms64. Check both of them and make sure the entire class is checked.



11.  Click OK, then click OK two more times to exit out of all windows.

Depending on how often you have Hardware Inventory scheduled to run, it can take a few days to get a good amount of data. Force a Hardware Inventory to run on a few machines to verify the data is being collected and create the report.

Create the Reports


SCCM 2012 uses SSRS for report creation. Go to your SSRS server for Configuration Manager and create a new report wherever appropriate in your environment. Below are the queries for 32-Bit and 64-Bit applications.

Use the following query for 32-Bit Applications:

SELECT DISTINCT v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 as 'Software Name' ,v_GS_ADD_REMOVE_PROGRAMS.Version0 as 'Software Version' ,v_GS_ADD_REMOVE_PROGRAMS.UninstallString0 as 'Uninstall String'
FROM v_GS_ADD_REMOVE_PROGRAMSWHERE v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 LIKE @SoftwareName

Use the following query for 64-Bit Applications:

SELECT DISTINCTv_GS_ADD_REMOVE_PROGRAMS_64.DisplayName0 as 'Software Name',v_GS_ADD_REMOVE_PROGRAMS_64.Version0 as 'Software Version',v_GS_ADD_REMOVE_PROGRAMS_64.UninstallString0 as 'Uninstall String'FROMv_GS_ADD_REMOVE_PROGRAMS_64WHEREv_GS_ADD_REMOVE_PROGRAMS_64.DisplayName0 LIKE @SoftwareName

The 32-Bit report is likely the one that will be used the most because a majority of applications are installed as 32-Bit by default or do not have a 64-Bit version. For the @SoftwareName parameter, I set a default value of %notepad++%. This is not required, however, I set it so users that have access to the report understand the format of the search to use. The % signs are required because we are using LIKE in the query. If "=" was used, the exact name of the software would be needed instead.

Run the report to verify it is pulling data. If no data is found, make sure at least one machine has done a Hardware Inventory and try it again. Also make sure you are searching for software you know is installed on the machine. It may take a few minutes for machines to report the data and SCCM to process it so it shows in the report. As more machines report in, the report will continue to grow as well.

The results will show the Uninstall String value for every version of the software found. I export to .CSV and filter out the duplicates and use that in my package/script for uninstalls.

No comments:

Post a Comment