Solved

vb script does not work in xenapp 6.5

Posted on 2013-06-16
6
1,435 Views
Last Modified: 2013-07-17
This vb script is used to create a list of users logged into a Citrix 4.5 MetaFrame farm.  We are migrating to XenApp 6.5 and the script does not work.  It does not error, it just does not return any data.  Here is the info the script returns: <user>; <server>; <workstation>;  <published app>; <ip address>;  <connection>.  An example of the results is shown below.

Sun 06/16/2013    5:48:23.97  CITRIX4  
user15      CITRIX7      WKS2748      Pub Desktop 1      192.168.1.18      ICA-tcp#1
user16      CITRIX3      WKS2653      Pub Desktop 1      192.168.1.12      ICA-tcp#1
user17      CITRIX8      WKS2652      Pub Desktop 1      192.168.1.11      ICA-tcp#2
Active Session Count = 3
Total Session Count = 3
On Error Resume Next
Const cMetaFrameWinFarmObject = 1
Const MFSessionStateActive = 1
Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
theFarm.Initialize(cMetaFrameWinFarmObject)
intSessionCount = 0
intActiveCount = 0
For Each oSession In theFarm.Sessions
  intSessionCount = intSessionCount + 1
    If (oSession.SessionState = MFSessionStateActive) and (oSession.SessionName <> "Console") Then
        intActiveCount = intActiveCount + 1
          If isnull(oSession.ClientAddress) or oSession.ClientAddress = ""  then
             WScript.Echo oSession.UserName & vbTab & vbTab & oSession.ServerName & vbTab & vbTab & oSession.ClientName & vbTab & vbTab & oSession.AppName & vbTab & oSession.SessionName 
          Else      
             WScript.Echo oSession.UserName & vbTab & vbTab & oSession.ServerName & vbTab & vbTab & oSession.ClientName & vbTab & vbTab & oSession.AppName & vbTab & vbTab & oSession.ClientAddress & vbTab & vbTab & oSession.SessionName 
          End If
  End If
Next
WScript.Echo "Total Session Count = " & intSessionCount & vbcrlf & "Active Session Count = " & intActiveCount

Open in new window

0
Comment
Question by:epmmis
  • 3
  • 2
6 Comments
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
I believe I have something like this in powershell...would you be interested in that?
Otherwise, remove the "On Error" statement at the top so you can see where it's failing...
0
 
LVL 23

Expert Comment

by:Coralon
Comment Utility
You will definitely want to convert to powershell for XA 6.5.  

This one should get what you need, although my results on the client IP address are mixed..

add-pssnapin citrix* -erroraction silentlycontinue
write-host (get-date) $env:computername
get-xasession -farm | select-object -property AccountName,MachineName,ClientName,BrowserName,ClientIP4,SessionName | format-table

Open in new window


That's pretty close to the output you had.. Getting those last couple of lines would be trickier.  

Coralon
0
 
LVL 23

Accepted Solution

by:
Coralon earned 500 total points
Comment Utility
Minor syntax correction :-)

add-pssnapin citrix* -erroraction silentlycontinue
write-host (get-date) $env:computername
get-xasession -farm | select-object -property AccountName,ServerName,ClientName,BrowserName,ClientIP4,SessionName | format-table

Open in new window


Coralon
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:epmmis
Comment Utility
This is a fantastic start.  Here is a sample output.  The IP would be nice, but I can live without if it is seriously complicated to retriever.  

AccountName   ServerName    ClientName   BrowserName  ClientIP4    SessionName
DOM\User1      WINCTX02         PC12345          Pub Desktop                            ICA-TCP#0  
DOM\User1      WINCTX03         PC12345          Pub Desktop                            ICA-TCP#0  
DOM\User2      WINCTX01         PC54321                                                              ICA-TCP#0

What other properties are available in the get-xasession -farm object?

Please excuse my delay but today was go live day.

Is there a way to get the total number users on the farm?
0
 
LVL 23

Expert Comment

by:Coralon
Comment Utility
I believe you can the total number of users, but I'm not sure how to get it.. I'm still learning powershell :-)

But, if you want to see what is available, that's very easy.
get-xasession -farm | get-member

Open in new window


Coralon
0
 

Author Closing Comment

by:epmmis
Comment Utility
The script provides the information I need.
Thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
Citrix XenDesktop 7.6 Citrix Policies Audio
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now