Showing posts with label Citrix XenApp. Show all posts
Showing posts with label Citrix XenApp. Show all posts

Wednesday, March 2, 2016

Citrix XenApp 7.7 : PowerShell Script To Get Applications Published To A User

PowerShell script to get applications subscribed by a user or published to a user in Citrix Xenapp 7.7

Earlier we saw that how to publish applications in Citrix XenApp 7.7 using PowerShell and add the required user to the published application's AssociatedUsers Property/Array. Refer the following link for the same: 



After the applications are published and the users who want to use particular applications are added, there may be a need to get the list of Applications that the user has subscribed to/applications published to the user. This is the purpose of this post. The following script accepts UserId as the input parameter and then iterates through each of the published applications to find out all those applications which have the user's name in their AssociatedUsers Property. All the App names which satisfy this criteria are collected in an array and then printed. I have also tried my best add as many as possible comments so that the script is easy to understand. Also I have given a link at the end of the page from which you can download the below script.


You can download the script from the below link:

#-------------------------------------------------------------------------------------------
# Purpose : This Script gives the list of applications that a user(say sam.ray@mycompany.com) has subscribed to.
# Author : Sam Ray
# Email  : prac.codes@gmail.com
# Input Parameters : UserId 
#-------------------------------------------------------------------------------------------


#-------------------------------------SCRIPT STARTS HERE-------------------------------------#


# Getting the first parameter passed (This parameter is the userid e.g sam.ray@mycompany.com)
$userid=$args[0]

# Making an empty application array which will contain all the apps that are subscribed by the user
$AppArray = @()

# Adding Citrix PoweShell SnapIns
If ( (Get-PSSnapin -Name Citrix* -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PSSnapin Citrix*
}

# The following code gets the apps that user has subscribed and adds them to the $AppArray.
# Logic : 1) Get all the published applications.
#         2) Check for the obtained userid's entry in every application's AssociatedUserUPNs property/array.
#         3) If present - add that application to $AppArray, else go to the next application and repeat...

foreach($application In Get-BrokerApplication)
{
 #Write-Host $application.ApplicationName
 foreach($user In $application.AssociatedUserUPNs)
 {
  #Write-Host $user
  if($user -eq $userid)
  {
   #Add this application to the array of applications for the user
   $AppArray += $application.ApplicationName
  }
 }
}

# Print the $AppArray to show the list of users that the user has subscribed to. (e.g. VLC, Notepad++, etc...)
foreach($app In $AppArray)
{
 Write-Host $($app + "," )
}

#-------------------------------------SCRIPT ENDS HERE-------------------------------------#  

You can download the script from the below link (Hosted on Google Drive):
Get User Subscribed Apps PoweShell Script

Thanks!!  

Tuesday, March 1, 2016

Citrix XenApp 7.7 : PowerShell Script To Publish Applications

PowerShell Script To Publish Applications in Citrix XenApp 7.7


I recently had an opportunity to play with Citrix Products and I learnt and did many cool things. First of all, let me tell you that Citrix is really a giant in Application Delivery domain and has a great community of experts. I started by installing Citrix XenApp 7.7 on my Windows Server 2012 R2 which is hosted on Microsoft Azure. Just to save the cost and as I wanted to have a simple Lab environment, I also installed Citrix StoreFront 2.6 on the same machine/server. There are many posts on how to configure Citrix XenApp and Storefront for application delivery and related stuff like authentication using Active Directory, etc ... But I really didn't find much help when it came to Application Publishing using PoweShell in XenApp. Hence I felt that I should write about whatever I did in the whole process.

There are 3 main components of Citrix Application Delivery Infrastructure:

1) StoreFront 
2) Delivery Controller (DC) 
3) Virtual Delivery Agent (VDA)

I installed about 20 applications (vlc, mozilla,etc.. ) on the same machine. Now I wanted to automate the process of publishing the Apps using PowerShell Script. The benefit of writing this script was that I could easily make a website which acted like an App Store using the Citrix SDK.

After installing all the components on the same machine, I also installed nearly twenty applications manually on my server (you can do that using script too :) ). Now I was in a position to publish the application I want using the PowerShell Script. Let us understand the various inputs that this PowerShell Script accepts and the various operations it performs:

Input Parameters:

1) User Id - The user which has to be added to the application (or to which application has to be assigned).

2) Action - Depending upon this parameter we add the user to the Published Application's AssociatedUser's array/property or remove the user from it.

3) AppName - The name of the Application for which the action has to be taken.

Operations:

1) The script first checks if the application is published or not. 
2) If not published, firstly the script publishes the App.
3) If the App is already published or after publishing it, then depending upon the Action parameter, the user is added to the Application's AssociatedUsers Array/Property or removed from it.

The following script implements the above behavior:

#-------------------------------------------------------------------------------------------
# PLEASE NOTE : Assumption - Applications are installed already on the machine.
# Purpose : This Script publishes the application(if not already published), and then adds the user to the Application's associated Users
# Author : Sam Ray
# Email  : prac.codes@gmail.com
# Input Parameters : UserId Action(subscribe/unsubscribe) AppName 
#-------------------------------------------------------------------------------------------


#-------------------------------------SCRIPT STARTS HERE-------------------------------------#


# Getting the first parameter passed (This parameter is the userid, e.g. sam.ray@mycompany.com)
$userid=$args[0]

# Getting the usename i.e. the part before the @ symbol
$splitUserName = $userid -split "@"
$username = $splitUserName[0]

# Getting the Second parameter passed (This parameter is either subscribe or unsubscribe action param)
# Depending upon this parameter, we add the user to a specific application or remove the user from the application
$action=$args[1]

# Getting the App Name on which action has to be performed
$appname = $args[2]

#Variable used to decide App is published or not
$Published = "false"

# Adding Citrix PowerShell SnapIns
If ( (Get-PSSnapin -Name Citrix* -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PSSnapin Citrix*
}

#Publish the required App if its not already published
#Check if it is published or not

foreach($application In Get-BrokerApplication)
{
 #Compare recieved Appname with the Published Appname
 if($application.ApplicationName -eq $appname)
 {
  $Published = "true"
  break
 }
 
}

#If App is not published then publishing App
if($Published -eq "false")
{
 switch ($appname) 
    { 
        "BlueStacks" {
                      
                       $path="C:\ProgramData\BlueStacksGameManager\BlueStacks.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name BlueStacks -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

        "Dropbox"    {
                      
                       $path="C:\Program Files (x86)\Dropbox\Client\Dropbox.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name Dropbox -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

        "Evernote"   {
                      
                       $path="C:\Program Files (x86)\Evernote\Evernote\Evernote.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name Evernote -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

        "OneDrive"   {
                      
                       $path="C:\Users\itadmin\AppData\Local\Microsoft\OneDrive\OneDrive.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       #New-BrokerApplication -Name OneDrive -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                       New-BrokerApplication -Name OneDrive -CommandLineExecutable "C:\Users\itadmin\AppData\Local\Microsoft\OneDrive\OneDrive.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                     
                     }

        "VLC"        {
                      
                       $path="C:\Program Files\VideoLAN\VLC\vlc.exe"
                       $IconPath = "Get-CtxIcon -IconData (Get-Content C:\Users\itadmin\Desktop\Vlc-icon.ico -Encoding Byte)"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       # Use the below type if you explicitly have icons in a folder
                       #$ctxIcon = Get-CtxIcon -IconData (Get-Content "C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT\ico_icons\Vlc-icon.ico" -Encoding Byte)
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name VLC -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

        "Notepad++"  {
                      
                       $path="C:\Program Files (x86)\Notepad++\notepad++.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name Notepad++ -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

                      
                      
        "MyWIFIRouter" {
                        
                         $path="C:\Program Files (x86)\Wi-Fi\Wi-Fi.exe"
                         Add-PSSnapin Citrix.Common.Commands
                         #$ctxIcon = Get-CtxIcon -FileName $path -index 0
          $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\Wi-Fi\Wi-Fi.exe" -index 0
                         $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                         #New-BrokerApplication -Name MyWIFIRouter -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
          New-BrokerApplication -Name MyWIFIRouter -CommandLineExecutable "C:\Program Files (x86)\Wi-Fi\Wi-Fi.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                        

                      }

                     
        "Mozilla"  {  
                       
                       $path="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name Mozilla -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }
                     
       "Opera"       {
                      
                       $path="C:\Program Files (x86)\Opera\launcher.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name Opera -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

                    
       "Yahoo"       {
                      
                       $path="C:\Program Files (x86)\Yahoo!\Messenger\YahooMessenger.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name Yahoo -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     } 

       "AIMP"        {
                      
                       $path="C:\Program Files (x86)\AIMP3\AIMP.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name AIMP -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      

                     }

      "Winamp"      {
                      
                       $path="C:\Program Files (x86)\Winamp\winamp.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       #$ctxIcon = Get-CtxIcon -FileName $path -index 0
        $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\Winamp\winamp.exe" -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       #New-BrokerApplication -Name Winamp -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                       New-BrokerApplication -Name Winamp -CommandLineExecutable "C:\Program Files (x86)\Winamp\winamp.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       
                      
                    }

      "FileZilla"    {
                      
                       $path="C:\Program Files\FileZilla FTP Client\filezilla.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name FileZilla -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

      "PaintDotNET"    {
                      
                       $path="C:\Program Files\paint.net\PaintDotNet.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name PaintDotNet -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

      "FoxitReader"  {
                      
                       $path="C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe"
                       Add-PSSnapin Citrix.Common.Commands
                       $ctxIcon = Get-CtxIcon -FileName $path -index 0
                       $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                       New-BrokerApplication -Name FoxitReader -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                      
                      
                     }

     

      "OpenOffice"    {
                       
                        $path="C:\Program Files (x86)\OpenOffice 4\program\soffice.exe"
                        Add-PSSnapin Citrix.Common.Commands
                        #$ctxIcon = Get-CtxIcon -FileName $path -index 0
         $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\OpenOffice 4\program\soffice.exe" -index 0
                        $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                        #New-BrokerApplication -Name Open Office -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
         New-BrokerApplication -Name OpenOffice -CommandLineExecutable "C:\Program Files (x86)\OpenOffice 4\program\soffice.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                       
                       
                     }

      "TeamViewer"    {
                       
                        $path="C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
                        Add-PSSnapin Citrix.Common.Commands
                        #$ctxIcon = Get-CtxIcon -FileName $path -index 0
         $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -index 0
                        $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                        #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
         New-BrokerApplication -Name TeamViewer -CommandLineExecutable "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                       
                     }

      "EssentialPIM"  {
                       
                        $path="C:\Program Files (x86)\EssentialPIM\EssentialPIM.exe"
                        Add-PSSnapin Citrix.Common.Commands
                        #$ctxIcon = Get-CtxIcon -FileName $path -index 0
         $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\EssentialPIM\EssentialPIM.exe" -index 0
                        $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                        #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
         New-BrokerApplication -Name EssentialPIM -CommandLineExecutable "C:\Program Files (x86)\EssentialPIM\EssentialPIM.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                       
                       
                     }
     
  "AceAccounting"  {
                      
                        $path="C:\ACE9\Ace9.EXE"
                        Add-PSSnapin Citrix.Common.Commands
                        #$ctxIcon = Get-CtxIcon -FileName $path -index 0
         $ctxIcon = Get-CtxIcon -FileName "C:\ACE9\Ace9.EXE" -index 0
                        $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                        New-BrokerApplication -Name AceAccounting -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid -IconUid $brokerIcon.Uid
         #New-BrokerApplication -Name AceAccounting -CommandLineExecutable "C:\ACE9\Ace9.EXE" -DesktopGroup "My Comapny Delivery Group"
                       
                       
                     }
     
  "AutoCAD"      {
                     
                      $path="C:\Program Files\Autodesk\AutoCAD 2016\acad.exe"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Autodesk\AutoCAD 2016\acad.exe" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name AutoCAD -CommandLineExecutable "C:\Program Files\Autodesk\AutoCAD 2016\acad.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                     
                    }
     
     
 "Outlook2013"      {
                    
                      $path="C:\Program Files\Microsoft Office\Office15\OUTLOOK.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\OUTLOOK.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "Outlook2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\OUTLOOK.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }
    
  
  "Word2013"      {
                     
                      $path="C:\Program Files\Microsoft Office\Office15\WINWORD.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\WINWORD.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "Word2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\WINWORD.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                     
                     
                    }
     "OneNote2013"      {
                    
                      $path="C:\Program Files\Microsoft Office\Office15\ONENOTE.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\ONENOTE.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "OneNote2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\ONENOTE.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                     
                    }

   "PowerPoint2013"      {
                     
                      $path="C:\Program Files\Microsoft Office\Office15\POWERPNT.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\POWERPNT.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "PowerPoint2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\POWERPNT.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                     
                    }

   "Excel2013"      {
                    
                      $path="C:\Program Files\Microsoft Office\Office15\EXCEL.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\EXCEL.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "Excel2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\EXCEL.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }
     
   "SkypeForBusiness2016"      {
                    
                      $path="C:\Program Files\Microsoft Office\Office16\lync.exe"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office16\lync.exe" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "SkypeForBusiness2016" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office16\lync.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }

   "OracleSqlDeveloper"      {
                    
                      $path="C:\Program Files (x86)\sqldeveloper\sqldeveloper\bin\sqldeveloper.exe"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\sqldeveloper\sqldeveloper\bin\sqldeveloper.exe" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "OracleSqlDeveloper" -CommandLineExecutable "C:\Program Files (x86)\sqldeveloper\sqldeveloper\bin\sqldeveloper.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }

   "TaskCoach"      {
                    
                      $path="C:\Program Files (x86)\TaskCoach\taskcoach.exe"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\TaskCoach\taskcoach.exe" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "TaskCoach" -CommandLineExecutable "C:\Program Files (x86)\TaskCoach\taskcoach.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }
 
  "Publisher2013"      {
                    
                      $path="C:\Program Files\Microsoft Office\Office15\MSPUB.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\MSPUB.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "Publisher2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\MSPUB.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }  
  

  "Klok2"      {
                    
                      $path="C:\Program Files (x86)\Klok2\Klok2.exe"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files (x86)\Klok2\Klok2.exe" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "Klok2" -CommandLineExecutable "C:\Program Files (x86)\Klok2\Klok2.exe" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    } 

    "Access2013"      {
                    
                      $path="C:\Program Files\Microsoft Office\Office15\MSACCESS.EXE"
                      Add-PSSnapin Citrix.Common.Commands
                      #$ctxIcon = Get-CtxIcon -FileName $path -index 0
       $ctxIcon = Get-CtxIcon -FileName "C:\Program Files\Microsoft Office\Office15\MSACCESS.EXE" -index 0
                      $brokerIcon = New-BrokerIcon -EncodedIconData $ctxIcon.EncodedIconData
                      #New-BrokerApplication -Name Team Viewer -CommandLineExecutable $path -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
       New-BrokerApplication -Name "Access2013" -CommandLineExecutable "C:\Program Files\Microsoft Office\Office15\MSACCESS.EXE" -DesktopGroup "My Comapny Delivery Group" -IconUid $brokerIcon.Uid
                    
                    }  
  

    }

}

#Subscribing/Unsubscribing according to action and passed username
switch ($action) 
    { 
        "subscribe" {
                      Add-BrokerUser $("MYCOMPANY\" + $username) -Application $appname
                      #Write-host "User successfully subscribed to requested App"  
                    }

        "unsubscribe"    
                    {
                      Remove-BrokerUser $("MYCOMPANY\" + $username) -Application $appname
                      Write-host "User successfully unsubscribed to requested App"  
                   
                     }

   

    }
 
 

  

You can download the script from the following link:
Download the above PowerShell Script (Hosted on Google Drive)

Thanks!!   .