Solved

vb script does not work in xenapp 6.5

Posted on 2013-06-16
6
1,495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 39251169
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 25

Expert Comment

by:Coralon
ID: 39252510
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 25

Accepted Solution

by:
Coralon earned 500 total points
ID: 39252652
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
ID: 39261070
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 25

Expert Comment

by:Coralon
ID: 39261248
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
ID: 39335216
The script provides the information I need.
Thanks
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
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…

687 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