VBscript to get Citrix published application details

Hello All, Below script will collect the information of published applications in citrix farm.

This script to be run on citrix server where excel is installed. output of this script will be an excel file.


<package>
    <job id="WhereIs">
     <reference object="MetaFrameCOM.MetaFrameFarm"/>

        <script language="VBScript">
Dim mfFarm
Dim mfApp
Dim mfGrp
Dim mfUsr
Dim mfSvr
Dim n
on error resume next
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = FALSE
Set objWorkbook = objExcel.Workbooks.Add
Set objWorksheet = objWorkbook.Worksheets(1)
r=1
c=1
objWorksheet.Cells(1,1)="Application Name"
objWorksheet.Cells(1,2)="Status"
objWorksheet.Cells(1,3)="Users"
objWorksheet.Cells(1,4)="NT Groups"
objWorksheet.Cells(1,5)="Servers"
objWorksheet.Cells(1,6)="Application Folder"
objworksheet.range("A1:F1").font.size= 12
objworksheet.range("A1:F1").font.bold= True

   
    Set mfFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
    mfFarm.Initialize 1
   
    WScript.Echo "Started Application Query... Wait for completed message"
    r=2
    For Each mfApp In mfFarm.Applications
        mfApp.LoadData 1

 r2=r
 r3=r
 r4=r
 'WScript.Echo "Published Application - " & mfApp.Appname
 objWorksheet.Cells(r,1)=mfApp.Appname
 objWorksheet.Cells(r,6)=mfApp.ParentFolderDN
 if mfApp.EnableApp=1 Then
  objWorksheet.Cells(r,2)="Enabled"
 Else
  objWorksheet.Cells(r,2)="Disabled"
 End If

        For Each mfGrp In mfApp.Groups
  objWorksheet.Cells(r2,1)=mfApp.AppName
  objWorksheet.Cells(r2,6)=mfApp.ParentFolderDN
  objWorksheet.Cells(r2,4)=mfGrp.GroupName
  r2=r2+1
        Next
        For Each mfUsr In mfApp.Users
  objWorksheet.Cells(r4,1)=mfApp.AppName
  objWorksheet.Cells(r4,6)=mfApp.ParentFolderDN
  objWorksheet.Cells(r4,3)=mfUsr.UserName
  r4=r4+1
        Next
 'WScript.Echo
 For Each mfSvr In mfApp.Servers
  objWorksheet.Cells(r3,1)=mfApp.AppName
  objWorksheet.Cells(r3,6)=mfApp.ParentFolderDN
  objWorksheet.Cells(r3,5)=mfSvr.ServerName
  r3=r3+1
 Next
 'WScript.Echo

 if r2>r3 then
    if r2>r4 then
  r=r2+1
    else
  r=r4+1
    end if
 else
    if r3>r4 then
  r=r3+1
    else
  r=r4+1
    end if
 end if
    Next
Set objrange = objWorksheet.Usedrange
objrange.entirecolumn.autofit()
    WScript.Echo "Completed"
        </script>
    </job>
</package>


Save this script with .wsf file extn and run the same..

***Share your comments about the post***

1 comment:

  1. thank you and please give java code to launched applications list.

    ReplyDelete