MMS 2016 User Personality Management–Application Mapping

MMS 2016 User Personality Management–Application Mapping

With the amount of content covered in today’s MMS 2016 session on User Personality Management, we didn’t get a chance to do a deeper dive into the application mapping and User Device Affinity installation methods in the Task Sequence.  Let’s start with the application mapping feature.

Microsoft Deployment Toolkit (MDT) has included Package Mapping capabilities for legacy Packages for several years, but the product was not updated to also include an equivalent capability for the new Application model introduced in ConfigMgr 2012.  However, because the MDT database is readily customizable and such customizations don’t threaten supportability the way modifying the ConfigMgr database does, it’s pretty simple to add this functionality independently.  There are only two main pieces involved: a table for mapping the apps, and a stored procedure to retrieve the apps. 

Here is the SQL to create the table:

/* Create ApplicationMapping table */
CREATE TABLE [dbo].[ApplicationMapping](
    [ARPName] [nvarchar](255) NULL,
    [Applications] [nvarchar](255) NULL
) ON [PRIMARY]

GO

And the SQL to create the Stored Procedure:

/* Create RetrieveApplications stored procedure (with wildcard) */
  CREATE  PROCEDURE [dbo].[RetrieveApplications] @MacAddress CHAR(17) AS   
  SET NOCOUNT ON   

/* Select and return all the appropriate records based on current inventory */  
  SELECT * FROM ApplicationMapping  
  WHERE EXISTS  
  (   
    SELECT *
    FROM CM_DB.dbo.v_GS_ADD_REMOVE_PROGRAMS a
    INNER JOIN CM_DB.dbo.v_GS_NETWORK_ADAPTER n ON a.ResourceID = n.ResourceID
    INNER JOIN CM_DB.dbo.v_R_System s on a.ResourceID = s.ResourceID
    WHERE MACAddress0 = @MacAddress
    AND DisplayName0 LIKE ARPName  
   ) OR EXISTS
   (   
    SELECT *
    FROM CM_DB.dbo.v_GS_ADD_REMOVE_PROGRAMS_64 a
    INNER JOIN CM_DB.dbo.v_GS_NETWORK_ADAPTER n ON a.ResourceID = n.ResourceID
    INNER JOIN CM_DB.dbo.v_R_System s on a.ResourceID = s.ResourceID
    WHERE MACAddress0 = @MacAddress
    AND DisplayName0 LIKE ARPName  
   )
GO

There are a few other versions of this Stored Procedure that have been provided, but this one contains some additional customizations.  Specifically, this incorporates the support for wildcards provided by Chris Nackers, adds the v_GS_ADD_REMOVE_PROGRAMS_64 view to account for 64-bit applications, and joins the v_R_System view to ensure that the device inventory being referenced is for a device that actually exists in ConfigMgr. The latter is necessary because network adapter information (including MAC address) and inventory are not actually directly dependent upon the machine record, so when a machine is deleted from ConfigMgr that inventory and NIC information are still available in the database.

Once these are created, you can insert mapping records into the ApplicationMapping table as needed.  The SQL is very simple:

/* Insert entries for app mapping */
INSERT INTO [dbo].[ApplicationMapping]
           ([ARPName],[Applications])
     VALUES
           (‘Microsoft Office Professional Plus 2016′,’Microsoft Office Professional Plus 2016’)
           ,(‘Microsoft Office Professional Plus 2013′,’Microsoft Office Professional Plus 2016’)
           ,(‘7-Zip 9.20 (x64 edition)’,’7-Zip 15.10 64-bit’)
           ,(‘7-Zip 15.10 (x64 edition)’,’7-Zip 15.10 64-bit’)
GO

The important thing to know with the table is that the first column needs to contain the application display name (or at least a portion of it) as it appears in Programs and Features on the machine, and the second column needs to be the display name of the ConfigMgr Application that should be installed.

All that is left now is to add a few pieces to your CustomSettings.ini file in your MDT Settings package:

[Settings]
Priority= RetrieveApplications, DynamicApplications
Properties=MyCustomProperty

[DynamicApplications]
SQLServer=<YOURSERVER>
Database=MDT
StoredProcedure=RetrieveApplications
NetLib=DBNMPNTW
Parameters=MacAddress
SQLShare=DeploymentShare$

Note – You may need to fix the permissions on your MDT deployment share in order to use it successfully for authentication.

So with all of this in place, when we run the ZTIGather process using that CustomSettings.ini file on a machine which had 7-Zip 9.20 and Notepad++ 5.9 (which does not include a version in the name)…

image

…we get application mapping entries to install 7-Zip 15.10 and Notepad++ 6.9.1

image

When the Install Applications task runs (using the COALESCEDAPPS base variable), the two apps automatically install without being explicitly called and without being deployed to the user or machine:

image

image

Note the setting required: “Allow this application to be installed from the Install Application task sequence action without being deployed.”

In the overall scenario we’re examining, this handles reinstallation of any applications that may have been installed either manually or as an optional user install. In the next post, we’ll take a look at automatically installing user-targeted applications during the Task Sequence.

Leave a Reply

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