Get user-targeted applications

The script dynamically creates task sequence variables for every Application that is targeted at the Primary User of the Device.

5 Star
2,018 times
Add to favorites
System Center
E-mail Twitter Digg Facebook
  • Application Mapping for machines getting Re-Imaged
    2 Posts | Last post January 14, 2015
    • Hi Peter,
      I am Haris. I need your suggestion and help on a request we have currently.
      Many of our client machines are getting reimaged to Windows7, we have SCCM 2012 R2 in our infrastructure.
      Our requirement is when we Re-image the machines, we need all the old applications mapped to the client machine to be available after re-imaging. 
      Note:- The hostnames of the client machines change once re-imaged
      Will your script help me fulfill my requirement, kindly advise.
      Thanks in Advance
    • Hi Harris,
      Sorry, for the late reply I didn't get a notification.
      This script is to get the user-targeted applications. In case you want to get the user-targeted applications this script will help. In case you want the computer-targeted applications, you might want to look at this:
      Do keep in mind that the computer-targeted script uses the computer name throughout the task sequence, so you might need to play a bit with the computer name as input.
  • Traverse folders
    1 Posts | Last post October 13, 2014
    • We have a User collection structure that have is like: User Collections -> Applications -> "Name of vendor" -> The AppCollection
      If I move the "App-collection" to the top Folder(Applications) it works great.
      Is it possible to Let the script traverse into those folders looking for collection.
      By the way realy neat and usefull script.
  • Having issue(s) with this script
    6 Posts | Last post August 28, 2014
    • My smsts.log is show an error with the Get-WmiObject command. It says something to the tune of "cannot find value for ComputerName parameter". It is referring to the $SiteServer variable I believe. I did create the 4 task sequence variables mentioned in the above description. I set my site server task sequence variable to the FQDN of the distribution point that I am PXE'ing from.
      Also, are the instructions in the link above ( still valid? For example, is "%_SMSTSMachineName%" the only input parameter needed in the "Parameters" field of the "Run PowerShell Script" step? Please advise. Thank you.
    • Let's start with the second question. Yes, that article is still up-to-date. The only required input variable is ResourceName, but then SiteCode, SiteServer and Container should be "hardcoded" in the script.
      Second, the SiteServer shouldn't point to your distribution point. It should point to your (primary) site server.
    • Thanks for the speedy response, Peter. Here is what I did to the script (still not working, but feel as if I am getting further. Details below).
      1. [CmdletBinding()]
      3. param (
      4.  [string]$ResourceName,
      5.  [string]$SiteCode,
      6.  [string]$SiteServer,
      7.  [string]$Container
      8.  )
      Modified version:
      1. [CmdletBinding()]
      2. $tsenv=New-Object -ComObject Microsoft.SMS.TSEnvironment
      3. $ResourceName=$tsenv.Value("_SMSTSMACHINENAME")
      4. $SiteCode=$tsenv.Value("_SMSTSSiteCode")
      5. $SiteServer="PRIMARYSERVER"
      6. $Container="AppsCollection"
      The reason why I went with this is because I was not sure how the script was getting the values of the variables in your original version (it wasn't working for me). I know how my "Modified" version works so it was just easier for me.
      As of now, it still fails, but it now gets further in to the script when it fails. It fails on line:
          $PrimaryUsers = (Get-WmiObject -ComputerName $SiteServer -Class SMS_UserMachineRelationship -Namespace root\SMS\Site_$SiteCode -Filter “ResourceName='$ResourceName' and IsActive='1' and Types='1'”).UniqueUserName.replace(“\”,”\\”)
      I also made the following change on that line above because the original line was not returning anything for me. So, instead of the above, I removed the "and Types='1'" portion of the -Filter parameter.
    • What error message do you get on that particular line? Also, did you try running the script out-side of a task sequence? Even though it will show some error about the specific task sequence objects, it will provide an output what the variables would be.
    • First, I want to say I really appreciate you taking the time out of your day and offering assistance to me. I will document all of this and make available on here as well as and pages. I have heard that others are interested in using this powershell function you wrote because it can be a huge timesaver. So, thank you, Peter.
      Back to the task at hand...
      When you say running the script outside the task sequence do you mean in the ISE or during the task sequence, hit F8 and run the script manually myself? 
    • No problem.
      I would test it the easy way, indeed for example via ISE. Simply hardcode the variables in the script and run it. It will probably provide errors about not being able to create task sequence objects/ variables, but it will also output the potential name of the task sequence variable and it value (via a simple Write-Host).