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/) ?