Your independent source for desktop virtualization, consumerization, and enterprise mobility management.
Sign in
|
Join
Desktop Virtualization
Consumerization
EMM
Forums
Videos
Podcasts
Books
Events
About Us
Discussion Forums
»
Tech Support Forums
»
Scripting / Automation
»
VBScript to enumerate pub apps and the users/groups they are published to on each server...
VBScript to enumerate pub apps and the users/groups they are published to on each server..., in the Scripting / Automation forum on BrianMadden.com
rated by 0 users
This post has 3 Replies | 0 Followers
Points 120
Reply
J G
Posted: Fri, Mar 3 2006 5:26 AM
rated by 0 users
I have a vbscript which I run on each of my citrix servers:
it creates a word report on all published apps on each server, the path etc etc...
I would like to know if there was any way that this report could be modified to also report the users/groups that each pub app is published to?
Here is the script:
'*** Script Start: ***
List All Apps On Server in the farm.
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: ListAllAppsOnServer.wsf
'
' AUTHOR: JG
' DATE : 05/09/2005
'
' COMMENT: List all apps on a server in the B& Citrix farm
'
'==========================================================================
'******************* 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 Message, theFarm, AppName ,anApp, aServer, Array()
Dim strUID, strPWD, ServerName, Found, outputfolder, outputfile, finaldoc, finalpath
Found = false
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, "\"))
'******************* If no command line argument *************************
' WScript.Echo "Please enter the Citrix server name"
' WScript.StdOut.Write "Please enter the Citrix server name: "
' Input = WScript.StdIn.ReadLine
Message = "Enter the ServerName"
Title = "Citrix Application Report"
strUID = InputBox(Message,Title,"**********", 100, 100)
' If WScript.Arguments.Count
' WScript.Echo "USAGE: ListAllAppsOnServer.wsf ServerName"
' WScript.Echo ""
' WScript.Echo "Example: ListAllAppsOnServer.wsf SRV1"
' WScript.Quit 0
' Else
'ServerName = WScript.Arguments(0)
ServerName = UCase(strUID)
' ServerName = UCase(Input)
'WScript.Echo "ListAllAppsOnServer Server: " & ServerName
'WScript.Echo ""
' End If
'******************* Create MetaFrameFarm object *************************
Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
if Err.Number
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
WScript.Echo "Can't Initialize MetaFrameFarm object"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if
'******************* 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 - " & ServerName
objSelection.TypeParagraph()
objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.Font.Size = "10"
'******************* Display all servers In the farm and display specified server in argument*************************
For Each aServer In theFarm.Servers
if Err.Number
WScript.Echo "Can't enumerate servers"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if
'if servername equals to farm server
if(ucase(aServer.ServerName)=ucase(ServerName)) Then
Found = true
For Each anApp In aServer.Applications
Set aWinApp = anApp.WinAppObject
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
'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
'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.TypeParagraph()
objSelection.Font.Size = "10"
objSelection.Font.Bold = False
Next
End If
Next
Set objDoc = Nothing
Set objWord = Nothing
Set oShell = Nothing
Set oFso = Nothing
Set oWshNetwork = Nothing
Set theFarm = Nothing
Set aWinApp = Nothing
WScript.Quit
'*** Script End ***
Any help would be much appreciated!
[:@]
Thanks
JG
| Post Points: 20
Reply
Guest
replied on
Fri, Mar 3 2006 8:07 AM
rated by 0 users
OK, not pretty but you'd be able to insert this code into your own where,
Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
theFarm.Initialize(MetaFrameWinFarmObject)
nAppCount = 0
For Each anApp In theFarm.Applications
if Err.Number
WScript.Echo "Can't enumerate applications"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if
anApp.LoadData(TRUE)
WScript.Echo "DistinguishedName: " & anApp.DistinguishedName
WScript.Echo "Name : " & anApp.AppName
WScript.Echo "Description : " & anApp.Description
WScript.Echo "Users : "
nUserCount = 0
For Each anUser In anApp.Users
'
' MetaFrameUser object.
'
If nUserCount = 0 then
WScript.Echo "Users : " & anUser.AAName & "/" & anUser.UserName
Else
WScript.Echo " " & anUser.AAName & "/" & anUser.UserName
End if
nUserCount = nUserCount + 1
Next
For Each anGroup In anApp.Groups
'
' MetaFrameGroup object.
'
If nUserCount = 0 Then
WScript.Echo "Users : " & anGroup.AAName & "/" & anGroup.GroupName
Else
WScript.Echo " " & anGroup.AAName & "/" & anGroup.GroupName
End If
nUserCount = nUserCount + 1
Next
WScript.Echo " " & nUserCount & " User(s)"
WScript.Echo "------------------------------------------------"
nAppCount = nAppCount + 1
Next
WScript.Echo nAppCount & " Application(s)"
WScript.Echo "Press ENTER to exit..."
WScript.StdIn.Read(1)
| Post Points: 20
Points 120
Reply
J G
replied on
Thu, Mar 9 2006 10:34 AM
rated by 0 users
Thanks - I took your advice and played about with the code and got it working eventually...
Thanks for your help!
JG
Thanks
JG
| Post Points: 20
Reply
Guest
replied on
Fri, Mar 17 2006 12:59 PM
rated by 0 users
Any chance you could post the completed code ?
| Post Points: 5
Previous
|
Next
Page 1 of 1 (4 items) |
RSS
Copyright © 1997-2013 TechTarget |
Disclosures
|
Privacy Policy
|
Contact Info
BrianMadden.com
|
SearchVirtualDesktop.com
|
SearchEnterpriseDesktop.com
|
SearchServerVirtualization.com
|
SearchVMware.com