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–

  • 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