XenApp: Automated content publish in XenApp


Purpose:

To publish content like “www.google.com” 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.

Install all the above components 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 of new folder under Applications folder {Applications/Test} – {Line 106}
  • Publishing content – {Line 108 – 115}
  • Addition of users/groups to the application –{Line 117-118}

    Script:

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

       2: # 

       3: # AUTHOR: Mohd Aslam

       4: # DATE  : 7/15/2010

       5: # 

       6: # COMMENT: This script will publish content like website in 

       7: #          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: $AppCons=$objAppCons.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 = "Publish 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_AppCon = New-Object System.Windows.Forms.Label

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

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

      71: $objLbl_AppCon.Text = "Content:"

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

      73:  

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

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

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

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

      78:  

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

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

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

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

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

      84:  

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

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

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

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

      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: If($AppCons.Substring(0,3) -eq "www")

     102: {

     103:     $AppCons = "http://" + $AppCons

     104: }

     105:  

     106: New-XAFolder Applications/Desktops

     107:  

     108: New-XAApplication -BrowserName $AppName `

     109: -ApplicationType "Content" `

     110: -ContentAddress $AppCons `

     111: -DisplayName $AppName -FolderPath "Applications/Desktops" `

     112: -Enabled $true `

     113: -AnonymousConnectionsAllowed $false `

     114: -AddToClientStartMenu $false `

     115: -ClientFolder "Desktops"`

     116:  

     117: Add-XAApplicationAccount -BrowserName $AppName `

     118: -Accounts $AppUsers.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, multiple data can be entered separated by “;”.

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

    image

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

    image

    Right click on Web-Contents icon and see the properties as below:

    image

     

                                                                    –Finish–

  • Advertisements

    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