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(";")