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!!   .

No comments:

Post a Comment

Thanks for your valuable comment