The script dynamically creates task sequence variables for every Application that is targeted at the Primary User of the Device. During this script variables with the name of APPIdXX will be created. So for usage within a task sequence fill in APPId as Base variable name. To use this script the following input variables are required:

Example: PowerShell.exe -ExecutionPolicy ByPass .\GetTargetedApplications_v0_9p.ps1 "CLDCLN02" "PCP" "CLDSRV02.PTCLOUD.LOCAL" "Application Deployment Collections"

For more information see: http://www.petervanderwoude.nl/post/install-user-targeted-applications-during-os-deployment-via-powershell-and-configmgr-2012/