Wednesday, April 1, 2015

Ever wish you could just link to an install in the AppCatalog?



In System Center Config Manager 2012r2 there isn't a built in way to send someone directly to a specific application (that I have ever seen reference to).

If you search the web, you'll find reference to deep linking, but only really in reference to the Windows 8.x Store (sideloaded apps).

Not the actual Application Catalog hosted internally.

This leads to:

Ever tell someone to go to the Application Catalog and install something?

Ever notice that some people find it hard to get to exactly what you want them to?

So let's just shoot them a direct link!

Go take a read right here:

Here's the code found on that Nickal Miron's Blog
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
#Dictionary values for encoding/decoding
$codes = @{}
$codes.Add('/', '2F00')
$codes.Add('_', '5F00')
$codes.Add('-', '2D00')
$codes.Add('0', '3000')
$codes.Add('1', '3100')
$codes.Add('2', '3200')
$codes.Add('3', '3300')
$codes.Add('4', '3400')
$codes.Add('5', '3500')
$codes.Add('6', '3600')
$codes.Add('7', '3700')
$codes.Add('8', '3800')
$codes.Add('9', '3900')
$codes.Add('a', '6100')
$codes.Add('b', '6200')
$codes.Add('c', '6300')
$codes.Add('d', '6400')
$codes.Add('e', '6500')
$codes.Add('f', '6600')
$codes.Add('o', '6F00')
$codes.Add('p', '7000')
$codes.Add('i', '6900')
$codes.Add('l', '6C00')
$codes.Add('n', '6E00')
$codes.Add('t', '7400')

$upperCodes = @{}

$upperCodes.Add('A', '4100')
$upperCodes.Add('B', '4200')
$upperCodes.Add('C', '4300')
$upperCodes.Add('D', '4400')
$upperCodes.Add('E', '4500')
$upperCodes.Add('F', '4600')
$upperCodes.Add('I', '4900')
$upperCodes.Add('S', '5300')


function encode([string]$AppID)

{
    $encoded = $null
    #foreach char in string, get encoded value from dictionary
    foreach ($char in [Char[]]$AppID)
    {
        #if char is uppercase look in uppercase dictionary
        if ([char]::IsUpper($char)) { $encoded = $encoded + $upperCodes.Get_Item($char.ToString()) }
        else { $encoded = $encoded + $codes.Get_Item($char.ToString()) }
    }
    return $encoded
}

function lookUpKey($code)

{
    $returnVal = $null
    #look in lowercase dictionary for code
    if ($codes.ContainsValue($code))
    {
        foreach ($key in ($codes.GetEnumerator() | Where-Object {$_.Value -eq $code}))
        {
            $returnVal = $key.Name
        }
    }
    #if not there look in uppercase dictionary
    elseif ($upperCodes.ContainsValue($code))
    {
        foreach ($key in ($upperCodes.GetEnumerator() | Where-Object {$_.Value -eq $code}))
        {
            $returnVal = $key.Name
        }
    }
    return $returnVal
}

function decode([string]$AppIDSig)

{
    $i = 0
    $Code = $null
    $decoded = $null

    foreach ($char in [Char[]]$AppIDSig)

    {
        #if less then 4 characters in code grab next character
        if ($i -le 3)
        {
            #build 4 char codes
            $code = $code + $char
            $i++
        }
        #if 4 characters are in code lookup the decoded value
        else
        {
            $decoded = $decoded + (lookUpKey $code)
        
            #reset code and start building 4 char code again
            $code = $char
            $i = 1
        }
    }
    #foreach statement does not iterate the last time to get last code, look up value for last code here
    $decoded = $decoded + (lookUpKey $code)

    return $decoded

}


That code is pretty darn awesome.

But the page lacks instructions on what a simple person like I should ACTUALLY do with it.

Step 1 - Go get an AppID!

  1. Open SCCM Console, then Software Library, Application Management, Applications. Right click the top header bar of your app's and check off "CI Unique ID".
  2. Select the Application you want, hit CTRL-C (don't right click and hit copy, then you're copying the application).
  3. Open Notepad, hit CTRL-V.
  4. Delete all the stuff before ScopeId_...
  5. Delete the trailing /## (This is the revision number of the Application. You cannot refer to a previous version of what you have currently deployed.)

Step 2 - Encode it!

  1. Paste that script into Powershell_ISE.
  2. I'm lazy, and I just throw at the end of the script "Encode ScopeID.../Application_..."
  3. Run the script.
  4. You get a massively long number.

Step 3 - I'm done right?

  1. Let's pretend this is your ApplicationCatalog link (that you'd click on in SoftwareCenter, or you wisely published to all desktops with a GPO).
  2. Cool! BingoBango throw that long number bit on the end and we're done right? Nope.
  3. That link shows your Library. We want an item from the Catalog.
  4. Adapt your link to look like the below:


That's it.

Now tell me how to do it better!

It would be pretty easy to just use PS to pull all the AppID's and spit you out ALL you links nice and neatly titled in a CSV.

Wonder if this ends up in the next iteration of Coretech's Application Approval Tool ( http://blog.coretech.dk/kea/coretech-application-e-mail-approval-tool/) ?


5 comments:

  1. Made a bit of an edit to the beginning to make it little clearer.

    ReplyDelete
  2. Where you did the change in script to run please let me know as I am new to shell scripting. .Thanks you

    ReplyDelete
    Replies
    1. First! Welcome to the world of PowerShell!

      Copy the code above to the clipboard, and paste it into Powershell_ISE. It should be 104 lines in length.

      Save the file as "SCCMDeepLinkConverter.ps1"

      Above I described myself as lazy, because in my file, line 105 reads:

      "encode ScopeId_092F8226-C53D-442B-BA21-C4E670C66ECF/Application_d160e6e0-7ac2-41b4-9f12-525a2ce274d2"

      So when I hit Run Script (F5), it spits out in the command window (blue with a prompt):

      "530063006F0070006500490064005F00300039003200460038003200320036002D0043003500330044002D0034003400320042002D0042004100320031002D00430034004500360037003000430036003
      6004500430046002F004100700070006C00690063006100740069006F006E005F00640031003600300065003600650030002D0037006100630032002D0034003100620034002D0039006600310032002D
      00350032003500610032006300650032003700340064003200"

      Then you add that to:

      https://Contoso/CMApplicationCatalog/#/SoftwareCatalog/AppDetails/

      Resulting in:
      https://Contoso/CMApplicationCatalog/#/SoftwareCatalog/AppDetails/530063006F0070006500490064005F00300039003200460038003200320036002D0043003500330044002D0034003400320042002D0042004100320031002D004300340045003600370030004300360036004500430046002F004400650070006C006F0065006E007400700065005F00640031003600300065003600650030002D0037006100630032002D0034003100620034002D0039006600310032002D00350032003500610032006300650032003700340064003200

      Now. The nicer, cleaner way to do this, is this. Delete that line 105 starting with Encode. Save the file.

      Close Powershell_ISE.

      Open Powershell_ISE.

      In the Command Window below in PowerShell_ISE, navigate to where you saved "SCCMDeepLinkConverter.ps1" then type (no quotes):

      ". .\SCCMDeepLinkConverter.ps1"

      You will get your prompt again. Then type:

      "encode ScopeId_092F8226-C53D-442B-BA21-C4E670C66ECF/Application_d160e6e0-7ac2-41b4-9f12-525a2ce274d2"

      Magically you will then get the full long string of numbers again.

      The command "encode" will be available so long as you keep the PowerShell session open. You can add that function to your installation of ISE by adding it to your Profile.

      Read this to get some information about dot sourcing: http://blogs.technet.com/b/heyscriptingguy/archive/2009/12/23/hey-scripting-guy-december-23-2009.aspx

      Delete
  3. Great article- thanks Jweinberg. If it's useful to anyone, you can also grab that ScopeID.... string (the "ModelName") for a given app from SCCM using PowerShell. Something like this works for me-
    #Load the SCCM PowerShell module
    Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'
    #Connect to my SCCM site (P01 is my site code)
    cd P01:
    #Get the ModelName for Acrobat
    (get-cmapplication -name "Adobe Acrobat XI").ModelName

    ReplyDelete
  4. Nice! I've seen something like that around. I'm going to be working a few things together for a neat little tool pretty soon.

    ReplyDelete