XenApp: Getting info about published Apps in a Farm using PowerShell

Purpose:

To find the name and folder location of applications published on a same farm in XenApp 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. This script can be extended to get more information about the published application.

Script:

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

   2: # 

   3: # AUTHOR: Mohd Aslam

   4: # DATE  : 6/22/2010

   5: # 

   6: # COMMENT: This script will get the name and location of all the

   7: # applicatios published in XenApp under same farm.

   8: # 

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

  10:  

  11: $colItems = Get-XAApplication 

  12:  

  13: foreach ($objItem in $colItems) {

  14: $AppName = “Application Name: ” + $objItem.DisplayName 

  15: $AppName | Out-file "C:\temp\PS\AppReport.txt" -Append

  16: $AppFolder = “Folder Path: ” + $objItem.FolderPath 

  17: $AppFolder | Out-file "C:\temp\PS\AppReport.txt" -Append

  18: $gap = " "

  19: $gap | Out-file "C:\temp\PS\AppReport.txt" -Append

  20: }

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 as: image    Result will be saved in a txt file “AppReport.txt”. Its content will be like:

Application Name: Excel

Folder Path: Applications/Office

Application Name: Desktop – ServerName

Folder Path: Applications/Desktops

Application Name: Notepad

Folder Path: Applications/Test
                                                                                  

Advertisements

XenApp: Disabling published App using PowerShell

Purpose:

To disable the published application in XenApp 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 two parts:

  • Creation of input box for application information – {Line 10 – 69}
  • Disabling the published application – {Line 71}

    Script:

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

       2: # 

       3: # AUTHOR: Mohd Aslam

       4: # DATE  : 6/22/2010

       5: # 

       6: # COMMENT: This script will disable the published App in XenApp

       7: # 

       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 = "Published application information"

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

      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,80)

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

      29: $OKButton.Text = "OK"

      30: $OKButton.Add_Click(

      31: {

      32: $AppName=$objAppName.Text;

      33: $objForm.Close()

      34: }

      35: )

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

      37:  

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

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

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

      41: $CancelButton.Text = "Cancel"

      42: $CancelButton.Add_Click(

      43: {

      44: $objForm.Close()

      45: }

      46: )

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

      48:  

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

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

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

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

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

      54:  

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

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

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

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

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

      60:  

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

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

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

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

      65:  

      66: $objForm.Topmost = $True

      67:  

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

      69: [void] $objForm.ShowDialog()

      70:  

      71: Disable-XAApplication $AppName

    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 the name of published application that needs to be disabled and click “Ok”. It will disable the application.

    To confirm the success, go to access management console and see the checkbox for “Disable application” checked  as shown below:image 

                                   –Finish–

  • XenApp: Automated Server Desktop publishing using PowerShell

    Purpose:

    To publish Server Desktop running 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 five parts:

  • Creation of input box for application information – {Line 9 – 98}
  • Creation of new folder under Applications folder {Applications/Desktops} – {Line 100}
  • Creation the published desktop – {Line 102-111}
  • Addition of users/groups to the application –{Line 113-114}
  • Assignment of servers to the published app –{Line 116-117}

    Script:

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

       2: # 

       3: # AUTHOR: Mohd Aslam

       4: # DATE  : 6/23/2010

       5: # 

       6: # COMMENT: This script publishes Server desktop running XenApp

       7: # 

       8: # ============================================================

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

      10: "System.Drawing") 

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

      12: "System.Windows.Forms") 

      13:  

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

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

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

      17: $objForm.StartPosition = "CenterScreen"

      18:  

      19: $objForm.KeyPreview = $True

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

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

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

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

      24:  

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

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

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

      28: $OKButton.Text = "OK"

      29: $OKButton.Add_Click(

      30: {

      31: $AppName=$objAppName.Text;

      32: $AppUsers=$objAppUsers.Text;

      33: $AppServers=$objAppServers.Text;

      34: $objForm.Close()

      35: }

      36: )

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

      38:  

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

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

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

      42: $CancelButton.Text = "Cancel"

      43: $CancelButton.Add_Click(

      44: {

      45: $objForm.Close()

      46: }

      47: )

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

      49:  

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

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

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

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

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

      55:  

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

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

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

      59: $objLbl_AppName.Text = "Publish Name:"

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

      61:  

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

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

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

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

      66:  

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

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

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

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

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

      72:  

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

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

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

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

      77:  

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

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

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

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

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

      83:  

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

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

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

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

      88:  

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

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

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

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

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

      94:  

      95: $objForm.Topmost = $True

      96:  

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

      98: [void] $objForm.ShowDialog()

      99:  

     100: New-XAFolder Applications/Desktops

     101:  

     102: New-XAApplication -BrowserName $AppName `

     103: -ApplicationType "ServerDesktop" `

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

     105: -Enabled $true `

     106: -AnonymousConnectionsAllowed $false `

     107: -AddToClientStartMenu $false `

     108: -InstanceLimit "-1" `

     109: -ColorDepth 1 `

     110: -AudioRequired $false `

     111: -ClientFolder "Desktops"`

     112:  

     113: Add-XAApplicationAccount -BrowserName $AppName `

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

     115:  

     116: Add-XAApplicationServer -BrowserName $AppName `

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

     118:  

     119:  

     120:  

     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–

  • XenApp: Publishing Server desktop

    For some non-windows clients or for some legacy applications, sometimes we needs to publish server desktop running XenApp. After publishing servers desktop, users are given access to server running XenApp and all the underlying resources, so it is risky as users can change any configuration of the underlying XenApp that may end up in messing the environment. To minimize risk, server desktop should not be published to less experienced users or if published, proper policies through GPO should be implemented.

    Access Management console is required to publish XenApp desktop.

    Below are the steps required to publish a Server desktop.

    Prerequisite:

    1. Citrix Access Management console should be installed on the XenApp farm.
    2. Person who is publishing server desktop should have full administrative rights on Access management console.

    Steps:

    1. Double click on the desktop icon “Access Management Console” or launch the exe “CmiLaunch.exe” from "C:\Program Files\Common Files\Citrix\Access Management Console – Framework\". Citrix Access Management console window will be launched. Left side of window will have tree structure as shown below. It has a node for Presentation server and under it, there is a node for XenApp farm. It has different folders under it to manage the farm. For this article, our interest is the “Applications” folder under it.           image 
    2. Right Click on “Applications” folder and Select New –> Create Folder as  shown below:            image
    3. Following screen will appear: image                                Enter the application name and click ok. It will create “Desktops” folder under the applications node.
    4. Right click on “Desktops” folder and select New –> Publish application. “Welcome” screen will appear: Click Next
    5. “Name” screen will appear, add the following details and Click Next:                                                                                     Display Name: desktop – SERVERNAME | Application description: desktop – SERVERNAMEimage
    6. “Type” screen will appear, Select the radio button for “Server desktop” and Click Next.                                                          image
    7. “Servers” screen will appear, Click on “Add” button to add all the servers whose desktop needs to be published. Servers added here will be having load balancing.image
    8. “Users” screen will appear for adding users who will have access rights on the published desktop. Click Add button and it will open “second screen”. On that screen, click on “Add List of Names” button to add the users. “third Screen” will appear. Enter the users into the screen and click “Check Names” button to see the validity of the entered users. Once verified click Ok. Click Ok on second screen and click Next on First screen.                              Note: You can add any number of users from the below screens but the best practice is to have active directory group containing all the required users and that group can be added directly to the below screen. With active directory group it is very easy to manage users. By manage I mean, addition and deletion of users.image
    9. “Shortcut Presentation” screen will appear. Enter “Desktops” folder in the textbox for “Client application folder”. If the user access is through web ICA, do not check the checkbox for “add to the client’s start menu” and “add shortcut to the client’s desktop”.                                                                                 Note: You should enter the folder name that you have created at step 2 above. Users will see the application icon under this folder in their web ICA session. image Check for the icon to be displayed to the users. If you want to change it, click on change icon button, following screen will appear, select the appropriate radio button and get the required icon and click Ok and then click Next to the parent screen.image
    10. “Publish immediately” screen will appear, select the checkbox for “Configure advanced application settings now” and click next.image
    11. Access control screen will appear: Keep the default options and click Next.image
    12. “Limits” screen will appear: Depending on the application architecture and the bandwidth, check the checkbox for “Limit instances allowed to run in server farm” and then add Maximum instances. Click Next.image
    13. “Client options” screen will appear: Select the different options based on your requirements like the bandwidth, security or printing requirements. Click Next.                                                  Note: For Client audio, refer to the article https://mdaslam.wordpress.com/2009/11/24/xenapp-legacy-audio/image
    14. “Appearance” screen will appear: Select the appropriate session window size and required color depth. Click Finish.                 Note: For seamless mode, selecting any value under “session window size” will not make any difference. For Color depth, refer to my article: https://mdaslam.wordpress.com/2009/09/22/xenapp-colors-depth-in-published-application-properties/image After this step, server desktop will be published and available under “Desktops” folder. Users who are given access to this icon, will be able to see it in Web ICA session.  

    To learn how to publish application in XenApp, refer to my article https://mdaslam.wordpress.com/2010/06/10/application-publish-in-xenapp/

                                                                –Finish–