november 2010 - Posts

[VB.net] Citrix XenApp 6.0 - SDK 6.1.2

Hello again,

I have created an application that can read and do a lot of stuff from the application to a farm in Cirtrix XenApp 6.0

 

But being a vb.net programmer and not a C# one, I didn't find what I was looking for on the net... so I wrote it myself.

 

Here you got the basic required funtion to connect a vb.net program to the cirtix XenApp SDK (powershell)

-----------------------------------------------------------------------------------------------------------------------------------

Private Sub GetCitrixInfo()


'Adding the default Runspace to the Form
Dim Runspace As Runspace
Runspace = CitrixRunspaceFactory.DefaultRunspace

'Now we have a runespace we need a pipeline (to send and receive objects from PowerShell)
Dim Pipeline As Pipeline
Pipeline = Runspace.CreatePipeline()

'Creating the command we want to send
'The Name of the Application
Dim GetSessionByApplicationsByName As New GetXASessionByApplicationName

Dim BrowserName As Array
BrowserName = {"*"}

Dim Commando
Commando = GetSessionByApplicationsByName.Command

'Adding the command to the pipeline
Pipeline.Commands.Add(Commando)

'We need to to give a variable which we will use in the Pipe

Dim results As Collection(Of PSObject)
results = Pipeline.Invoke()

'Now our variable will be filled by PowerShell objects, we need to translate them to .NET object

Dim app As PSObject
Dim allowedUsers As Dictionary(Of String, User)

For Each app In results
'app' is an instance of PSObject

Dim xaSession As XASession
xaSession = app.BaseObject


Dim item As New ListViewItem
item.SubItems.Add(xaSession.AccountName)
item.SubItems.Add(xaSession.BrowserName)
item.SubItems.Add(xaSession.ServerName)
item.SubItems.Add(xaSession.SessionId)
item.SubItems.Add(xaSession.ClientName)
SessionListView.Items.Add(item)


Catch ex As Exception
'Debugging

End Try
End If

Next

'Autosize Columns in the Listview
For Each column As ColumnHeader In Me.SessionListView.Columns
column.Width = -2
Next

progressBar.Style = ProgressBarStyle.Blocks

End Sub

----------------------------------------------------------------------------------------------------------------------------------

If you have more question on the subject, just ask ! :)