There are numerous guides showing how to configure MDT Package Mapping (otherwise known as Application Mapping or Application Migration), including an MSDN article (Link). That is not the aim of this post. I’ve just configured Package Mapping for use with OSD and came across some obstacles along the way. The aim of this post is to outline those obstacles and the steps taken to overcome them.
First of all I created the RetrievePackages stored procedure as per the MSDN article above. I, as lots have done before, decided to modify it slightly to use Add/Remove Programs display name rather than Product Code for simplicity and manageability. My stored procedure therefore looked like this:
/****** Object: StoredProcedure [dbo].[RetrievePackages] ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER PROCEDURE [dbo].[RetrievePackages]
SET NOCOUNT ON
/* Select and return all the appropriate records
based on current inventory */
SELECT * FROM PackageMapping
WHERE ARPName IN
SELECT DisplayName0 FROM SMS_XYZ.dbo.v_GS_ADD_REMOVE_PROGRAMS a,
WHERE a.ResourceID = n.ResourceID AND
MACAddress0 = @MacAddress
I then modified the CustomSettings.ini within my Settings Package to include the elements described in the MSDN article and sent it out to my distribution points. I populated the PackageMapping table with some test application display names and linked those to their equivalent package ID and program name. I ran the deployment process and of course, it failed.
There was no task sequence failure, and nothing was logged of interest in the SMSTS.log, the failure occured performing tasks against the MDT Database. The following was logged in the BDD.log when trying to execute the RetrievePackages procedure:
Error -2147217887 : Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
This error didn’t really seem to indicate anything in particular to me, so I decided that, like 90% of other database issues, the problem was down to permissions. The connection was being attempted using the computer’s machine account, and so as this was a variable that would change on every machine that would be built, I granted Connect, Select and Execute permissions on the MDT database for ‘Domain Computers’. I kicked off the process again, and again it failed with the same problem.
The step where the information contained within the CustomSettings.ini is retrieved and the information queried from wherever the CustomSettings.ini data references (in this case, the MDT Database) is part of the MDT task sequence item set, ‘Gather’. Looking in the task sequence for all instances of Gather I notice that the only one before the point where the machine gets joined to the Domain, is a local only gather. There was another gather that uses the rules within CustomSettings.ini, but this was after the Join Domain step. The point where the items retrieved from the CustomSettings.ini gets processed is the State Restore. I therefore needed another Gather between joining the Domain and performing the state restore. It was at this point that I decided to restructure it slightly to accomplish another requirement….
Package Mapping can’t be turned on or off on a per-machine basis. It’s either on for the task sequence, or off for the task sequence, and these changes involve modifying the CustomSettings.ini and sending the modified file out to all DPs. I decided I wanted to do something about this. I wanted the ability to have one Settings package that would stay on the DPs, but also have the ability to test Package Mapping before making it live, and have one task sequence that uses it, and one that does not, so that there’s a choice whether to Migrate Applications or not.
The permission changes I’d already made worked well and a connection to the database was succesfully performed, the procedure was successfully executed, the data was successfully retrieved, and the packages were installed as part of the ‘Install Multiple Applications’ step later on in the task sequence as additions to the MDT ‘PACKAGES’ base variable.
I then ended up with two task sequences, one that included the additional Gather to retrieve from the PackageMapping.ini that I could use to migrate applications (and to initially test the process), and one task sequence without this additional Gather which could be used to migrate user files and settings, but not applications.