[THIN] Re: Script to enumerate users\groups of Citrix published applications XP FR3

  • From: Marc-André Lapierre <malapierre@xxxxxxxxxxx>
  • To: thin@xxxxxxxxxxxxx
  • Date: Mon, 08 May 2006 16:28:36 -0400

That one will create you a word file with all the infos you need....

 

'*******************************************************************************

'Written by Michael Callahan

'Date: 01/06/2005

'

'AppReport.wsf

'

'Description: List all applications in a farm and the users and servers 
assigned to them

'Report  to Microsoft Word document.             

'Requires Microsoft Word be installed on the machine you are running this from!

'

'

'*******************************************************************************

<package>

    <job id=" FarmApplications">

 

        <comment>

 

        File:           AppReport.wsf

        Description:    List all applications in a farm and the users and 
servers assigned to them.

        Requirements:   WSH 5.5 or higher.

        

        

 

        </comment>

        <runtime>

            <description>

               List Servers and Users for all apps  in the farm.

            </description>

              

        </runtime>

        <reference object="MetaFrameCOM.MetaFrameFarm"/>

        <script language="VBScript">

       'On Error Resume Next

        'Create the Word document

        Set objWord = CreateObject("Word.Application")

            objWord.Visible = True

            Set objDoc = objWord.Documents.Add()

            Set objSelection = objWord.Selection

            objDoc.Paragraphs.KeepTogether = True

            

        

            Dim theFarm,AppName ,anApp,aServer, Array()

            

            '

            'Set up basic scripting objects

            '

            Set oShell = WScript.CreateObject("WScript.Shell")

                Set oFso = CreateObject("Scripting.FileSystemObject")

                Set oWshNetwork = WScript.CreateObject("WScript.Network")

                sScriptFullName = WScript.ScriptFullName

                sScriptPath = Left(sScriptFullName, InStrRev(sScriptFullName, 
"\"))

 

            

            '

            ' Create MetaFrameFarm object

            '

 

            Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")

            if Err.Number <> 0 Then

                WScript.Echo "Can't create MetaFrameFarm object"

                WScript.Echo "(" & Err.Number & ") " & Err.Description

                WScript.Echo ""

                WScript.Quit Err.Number

            End if

 

            '

            ' Initialize the farm object.

            '

 

            theFarm.Initialize(MetaFrameWinFarmObject)

            if Err.Number <> 0 Then

                WScript.Echo "Can't  Initialize MetaFrameFarm object"

                WScript.Echo "(" & Err.Number & ") " & Err.Description

                WScript.Echo ""

                WScript.Quit Err.Number

            End if

            

            '

            'Set  file

            '

            '

            '

            ' Are you Citrix Administrator?

            '

 

            If theFarm.WinFarmObject.IsCitrixAdministrator = 0 then

                WScript.Echo "You must be a Citrix admin to run this script" 

                WScript.Echo ""

                WScript.Quit 0

            End If

 

            '

            ' Print out the farm name.

            '

            WScript.Echo "MetaFrame Farm Name: " & theFarm.FarmName

            WScript.Echo ""

            objSelection.Font.Name = "Arial"

                objSelection.Font.Size = "18"

                objSelection.TypeText theFarm.FarmName & " Applications Report"

                objSelection.TypeParagraph()

                '

                objSelection.Font.Size = "14"

                objSelection.TypeText "" & Date()

                objSelection.TypeParagraph()

                objSelection.TypeParagraph()

            '

            '

            objSelection.Font.Size = "10"

            'Loop through all applications in the farm 

            

            For Each anApp In theFarm.Applications

            Set aWinApp = anApp.WinAppObject

 

                if Err.Number <> 0 Then

                    WScript.Echo "Can't enumerate applications"

                    WScript.Echo "(" & Err.Number & ") " & Err.Description

                    WScript.Echo ""

                    WScript.Quit Err.Number

                End if

              If aWinApp.PNAttributes AND MFWinAppDesktop Then 'If these values 
are True then it is a published desktop

              

              'WScript.Echo "Application Name: " & anApp.AppName

              objSelection.Font.Bold = True

              objSelection.TypeText "Application Name: "

              objSelection.Font.Bold = False

              objSelection.TypeText " " & anApp.AppName

              objSelection.TypeParagraph()

              

              'WScript.Echo "Distinguished Name: " & anApp.DistinguishedName

              objSelection.Font.Bold = True

                  objSelection.TypeText "Distinguished Name: "

                  objSelection.Font.Bold = False

                  objSelection.TypeText " " & anApp.DistinguishedName

              objSelection.TypeParagraph()

              

              'WScript.Echo "Command Line: " & "Published Desktop"

              objSelection.Font.Bold = True

                  objSelection.TypeText "Command Line: "

                  objSelection.Font.Bold = False

                  objSelection.TypeText " " & "Published Desktop"

              objSelection.TypeParagraph()

              

                                    If aWinApp.PNFolder <> "" Then

                            'WScript.Echo "Program Neighborhood Folder: " & 
aWinApp.PNFolder

                            objSelection.Font.Bold = True

                                    objSelection.TypeText "Program Neighborhood 
Folder: "

                                    objSelection.Font.Bold = False

                                    objSelection.TypeText " " & aWinApp.PNFolder

                                    objSelection.TypeParagraph()

                                    End If

              Else

              

              'WScript.Echo "Application Name: " & anApp.AppName

              'WScript.Echo "Application Name: " & anApp.AppName

                  objSelection.Font.Bold = True

                  objSelection.TypeText "Application Name: "

                  objSelection.Font.Bold = False

                  objSelection.TypeText " " & anApp.AppName

              objSelection.TypeParagraph()

              

              'WScript.Echo "Distinguished Name: " & anApp.DistinguishedName

                  objSelection.Font.Bold = True

                  objSelection.TypeText "Distinguished Name: "

                  objSelection.Font.Bold = False

                  objSelection.TypeText " " & anApp.DistinguishedName

              objSelection.TypeParagraph()

              

              'WScript.Echo "Command Line: " & aWinApp.DefaultInitProg

              objSelection.Font.Bold = True

                  objSelection.TypeText "Command Line: "

                  objSelection.Font.Bold = False

                  objSelection.TypeText " " & aWinApp.DefaultInitProg

              objSelection.TypeParagraph()

              

              'WScript.Echo "Working Directory: " & aWinApp.DefaultWorkDir

              objSelection.Font.Bold = True

                  objSelection.TypeText "Working Directory: "

                  objSelection.Font.Bold = False

                  objSelection.TypeText " " & aWinApp.DefaultWorkDir

              objSelection.TypeParagraph()

                                    If aWinApp.PNFolder <> "" Then

                                    'WScript.Echo "Program Neighborhood Folder: 
" & aWinApp.PNFolder

                                    objSelection.Font.Bold = True

                                    objSelection.TypeText "Program Neighborhood 
Folder: "

                                    objSelection.Font.Bold = False

                                    objSelection.TypeText " " & aWinApp.PNFolder

                                    objSelection.TypeParagraph()

                                    End If

              End If

              objSelection.TypeParagraph()

              objSelection.Font.Size = "10"

              objSelection.Font.Bold = True

                  objSelection.TypeText "" & "Servers: "

                  objSelection.TypeParagraph()

                  

                  objSelection.Font.Size = "10"

                  objSelection.Font.Bold = False

                

               'Print ServerName for the app.

               'Grab all servers into an array, then sort by name

               sCount = 0

                 For Each aServer In anApp.Servers

                 

                                                     ReDim Preserve 
array(sCount)

                                                             array(sCount) = 
aServer.ServerName

                                                             sCount = sCount + 1

                                                             Next

                                                                        For i = 
(UBound(array) - 1) to 0 Step -1

                                                                                
    For j= 0 to i

                                                                                
                If UCase(array(j)) > UCase(array(j+1)) Then

                                                                                
                strHolder = array(j+1)

                                                                                
                array(j+1) = array(j)

                                                                                
                array(j) = strHolder

                                                                                
                End If

                                                                                
    Next

                                                                        Next

                   

                   For i=0 to Ubound(Array) 'Output the sorted results

                 

                 'WScript.Echo "Server Name: " & Array(i)

                 objSelection.TypeText vbTab & Array(i)

                 objSelection.InsertParagraphAfter()

                                  

                 Next

                 objSelection.TypeParagraph()

              'WScript.Echo ""

              'objSelection.TypeParagraph()

                            

                  objSelection.Font.Size = "10"

                  objSelection.Font.Bold = True

                  objSelection.TypeText "" & "Users: "

                  objSelection.TypeParagraph()

                  

                  objSelection.Font.Size = "10"

                  objSelection.Font.Bold = False

                  

            'List users granted access to the published app

            For Each anUser In anApp.Users

                                            

                                                '

                                                ' MetaFrameUser object.

                                                '

                                                

                                                If nUserCount = 0 then

                                                            WScript.Echo "Users 
           : " & anUser.AAName & "\" & anUser.UserName

                                                            
objSelection.TypeText vbTab & anUser.AAName & "\" & anUser.UserName

                                                            
objSelection.TypeParagraph()

                                                            Else                
        

                                                            WScript.Echo "      
             " & anUser.AAName & "\" & anUser.UserName

                                                            
objSelection.TypeText vbTab & anUser.AAName & "\" & anUser.UserName

                                                            
objSelection.TypeParagraph()

                                                End if           

                                                

                                                

                                                

                Next    

                        objSelection.TypeParagraph()

                        objSelection.Font.Size = "10"

                        objSelection.Font.Bold = True

                        objSelection.TypeText "" & "Groups: "

                        objSelection.TypeParagraph()

                        

                        objSelection.Font.Size = "10"

                        objSelection.Font.Bold = False

                                            'List groups granted access to the 
published app

                                            For Each anGroup In anApp.Groups

                                            

                                                '

                                                ' MetaFrameGroup object.

                                                '

                            

                                                If nUserCount = 0 Then

                                                'WScript.Echo "Users            
: " & anGroup.AAName & "\" & anGroup.GroupName

                                                objSelection.TypeText vbTab & 
anGroup.AAName & "\" & anGroup.GroupName

                                                objSelection.TypeParagraph()

                                                Else

                                                'WScript.Echo "                 
  " & anGroup.AAName & "\" & anGroup.GroupName

                                                objSelection.TypeText vbTab & 
anGroup.AAName & "\" & anGroup.GroupName

                                                objSelection.TypeParagraph()

                                                End If    

                                            Next

           objSelection.TypeParagraph()

           objSelection.TypeParagraph()

           objSelection.InlineShapes.AddHorizontalLineStandard 'Add horizontal 
line between application sets

           Next

     'Save the doc, quit Word and clean up variables      

     objDoc.SaveAs sScriptPath & "\" & theFarm.FarmName & " Application 
Report.doc"        

    objDoc.Close

    objWord.Quit

    Set objDoc = Nothing

    Set objWord = Nothing

 

         </script>

    </job>

</package>

 

____________________________________________

Marc-André Lapierre, MALICIS Informatique Inc.

Consultant Senior / Senior Consultant

Tel: (514) 516-0040

malapierre@xxxxxxxxxxx

 

________________________________

De : thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] De la part de 
Parr, Steve
Envoyé : 8 mai 2006 16:09
À : thin@xxxxxxxxxxxxx
Objet : [THIN] Script to enumerate users\groups of Citrix published 
applications XP FR3

 

Does anyone know of a good\simple Script to enumerate all users and groups that 
have been given access to Citrix published applications; XP FR3?

 

Steve Parr
Metroland Printing, Publishing and Distributing Ltd.

 

Other related posts: