XenApp: Automated streaming package publish using PowerShell


Purpose:

To publish application streaming package in XenApp automatically using PowerShell script.

Pre-requisite:

Following are the prerequisites for setting up the environment to execute PowerShell script to publish application in XenApp:

  1. .Net Framework 3.5 SP1 {Download it from Microsoft website}
  2. Microsoft PowerShell 1.0 {Download it from Microsoft website}
  3. XenApp Command technology preview{Download it from citrix site: https://www.citrix.com/English/ss/downloads/details.asp?downloadId=1687620&productId=186#top} : These commands are a PowerShell Tool Pack that allows managing most aspects related to XenApp.  They cover all of MFCOM functionality for features available in XenApp 5 and include functionality from both AMC and CMC.
  4. Person who is publishing application icon should have full administrative rights on Access management console and should have atleast read access rights on the shared location where streaming package is stored.
  5. Application users should also has read access rights on the shared location where streaming package is stored.

Install all the above components {step 1 – 3} in the given order onto the XenApp environment.

Solution: 

Below script is the solution. It has four parts:

  • Creation of input box for application information – {Line 10 – 99}
  • Creation the published application icon for streaming package – {Line 101-117}
  • Addition of users/groups to the application –{Line 119-120}
  • Assignment of servers to the published app –{Line 122-123}

    Script:

       1: # =========================================================

       2: # 

       3: # AUTHOR: Mohd Aslam

       4: # DATE  : 7/06/2010

       5: # 

       6: # COMMENT: This script will publish application streaming 

       7: # package in XenApp.

       8: # 

       9: # =========================================================

      10: [void] [System.Reflection.Assembly]::LoadWithPartialName(

      11: "System.Drawing") 

      12: [void] [System.Reflection.Assembly]::LoadWithPartialName(

      13: "System.Windows.Forms") 

      14:  

      15: $objForm = New-Object System.Windows.Forms.Form 

      16: $objForm.Text = "Server Desktop publish information"

      17: $objForm.Size = New-Object System.Drawing.Size(430,200) 

      18: $objForm.StartPosition = "CenterScreen"

      19:  

      20: $objForm.KeyPreview = $True

      21: $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") 

      22:     {$x=$objTextBox.Text;$objForm.Close()}})

      23: $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") 

      24:     {$objForm.Close()}})

      25:  

      26: $OKButton = New-Object System.Windows.Forms.Button

      27: $OKButton.Location = New-Object System.Drawing.Size(190,140)

      28: $OKButton.Size = New-Object System.Drawing.Size(75,23)

      29: $OKButton.Text = "OK"

      30: $OKButton.Add_Click(

      31: {

      32: $AppName=$objAppName.Text;

      33: $AppUsers=$objAppUsers.Text;

      34: $AppServers=$objAppServers.Text;

      35: $objForm.Close()

      36: }

      37: )

      38: $objForm.Controls.Add($OKButton)

      39:  

      40: $CancelButton = New-Object System.Windows.Forms.Button

      41: $CancelButton.Location = New-Object System.Drawing.Size(290,140)

      42: $CancelButton.Size = New-Object System.Drawing.Size(75,23)

      43: $CancelButton.Text = "Cancel"

      44: $CancelButton.Add_Click(

      45: {

      46: $objForm.Close()

      47: }

      48: )

      49: $objForm.Controls.Add($CancelButton)

      50:  

      51: $objLabel = New-Object System.Windows.Forms.Label

      52: $objLabel.Location = New-Object System.Drawing.Size(10,15) 

      53: $objLabel.Size = New-Object System.Drawing.Size(280,20) 

      54: $objLabel.Text = "Please enter the information in the space below:"

      55: $objForm.Controls.Add($objLabel) 

      56:  

      57: $objLbl_AppName = New-Object System.Windows.Forms.Label

      58: $objLbl_AppName.Location = New-Object System.Drawing.Size(10,40) 

      59: $objLbl_AppName.Size = New-Object System.Drawing.Size(160,20) 

      60: $objLbl_AppName.Text = "Application Name:"

      61: $objForm.Controls.Add($objLbl_AppName) 

      62:  

      63: $objAppName = New-Object System.Windows.Forms.TextBox 

      64: $objAppName.Location = New-Object System.Drawing.Size(190,40) 

      65: $objAppName.Size = New-Object System.Drawing.Size(205,20) 

      66: $objForm.Controls.Add($objAppName) 

      67:  

      68: $objLbl_AppUsers = New-Object System.Windows.Forms.Label

      69: $objLbl_AppUsers.Location = New-Object System.Drawing.Size(10,70) 

      70: $objLbl_AppUsers.Size = New-Object System.Drawing.Size(160,20) 

      71: $objLbl_AppUsers.Text = "Application Users*:"

      72: $objForm.Controls.Add($objLbl_AppUsers) 

      73:  

      74: $objAppUsers = New-Object System.Windows.Forms.TextBox 

      75: $objAppUsers.Location = New-Object System.Drawing.Size(190,70) 

      76: $objAppUsers.Size = New-Object System.Drawing.Size(205,20) 

      77: $objForm.Controls.Add($objAppUsers) 

      78:  

      79: $objLbl_Server = New-Object System.Windows.Forms.Label

      80: $objLbl_Server.Location = New-Object System.Drawing.Size(10,100) 

      81: $objLbl_Server.Size = New-Object System.Drawing.Size(160,20) 

      82: $objLbl_Server.Text = "Servers*:"

      83: $objForm.Controls.Add($objLbl_Server) 

      84:  

      85: $objAppServers = New-Object System.Windows.Forms.TextBox 

      86: $objAppServers.Location = New-Object System.Drawing.Size(190,100) 

      87: $objAppServers.Size = New-Object System.Drawing.Size(205,20) 

      88: $objForm.Controls.Add($objAppServers) 

      89:  

      90: $objLbl_Server = New-Object System.Windows.Forms.Label

      91: $objLbl_Server.Location = New-Object System.Drawing.Size(10,120) 

      92: $objLbl_Server.Size = New-Object System.Drawing.Size(180,20) 

      93: $objLbl_Server.Text = "*: Enter ';' separated data if any"

      94: $objForm.Controls.Add($objLbl_Server) 

      95:  

      96: $objForm.Topmost = $True

      97:  

      98: $objForm.Add_Shown({$objForm.Activate()})

      99: [void] $objForm.ShowDialog()

     100:  

     101: New-XAApplication -BrowserName $AppName `

     102: -DisplayName $AppName -FolderPath "Applications/Office" `

     103: -Enabled $true `

     104: -ApplicationType StreamedToServer `

     105: –ProfileLocation "\\Server\App_Profiles\MSOffice - Word.profile" `

     106: –ProfileProgramName "Microsoft Office Word 2003" `

     107: –IconStream (

     108: Get-XAIconStream `

     109: -profilelocation "\\Server\App_Profiles\MSOffice - Word.profile" `

     110: -profileprogramname "Microsoft Office Word 2003" `

     111: –Index 0) `

     112: -AnonymousConnectionsAllowed $false `

     113: -InstanceLimit "-1" `

     114: -ColorDepth 1 `

     115: -AudioRequired $false `

     116: -ClientFolder "Office"`

     117: -ProfileProgramArguments %* `

     118:  

     119: Add-XAApplicationAccount -BrowserName $AppName `

     120: -Accounts $AppUsers.Split(";")

     121:  

     122: Add-XAApplicationServer -BrowserName $AppName `

     123: -ServerNames $AppServers.Split(";")

     How to Run above script?:

    Save above script to some location with .ps1 extension. To Run above script, go to “Programs > Citrix > XenApp Commands” and click “Windows PowerShell with XenApp Commands (CTP2)” icon. It will launch PowerShell command prompt.

    On the PowerShell command prompt, write script name with full location and click enter. Script will run and below screen will be displayed:

    image

    Enter all the required data and click “Ok”. For application users and servers, multiple data can be entered separated by “;”.

    Following screen will be displayed containing information about the published icon.

    image

    To confirm the successful publish, go to access management console and see the published icon as:

    image

                                                                    –Finish–

  • Advertisements

    One thought on “XenApp: Automated streaming package publish using PowerShell

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s