Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
users by group
Logged in as: Guest
arrSession:exec spGetSession 2,16,26914
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Post a VBScript
>> users by group
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
users by group -
10/13/2005 8:30:28 AM
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status:
offline
'========================================================================== ' ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1 ' ' NAME: Users by Group ' ' AUTHOR: Kirrilian ' Date : 6/15/2004 ' ' COMMENT: ' Usage: run script from command line With cscript, eg. cscript Users_by_Group.vbs ' By default there is a file specified as the input, or you can specify either an input ' file name or computer To connect to. Examples below. ' default input file: cscript Users_by_Group.vbs ' user specified input file: cscript Users_by_Group.vbs newinputfile.txt ' user specified hostname: cscript Users_by_Group.vbs hostname ' NOTE: this only works for ONE server when you specify it On the command line. ' The input file should just have one server name per line. '============================================================================ Dim singleComputer, InputFile Const OutputFile = "./Users_by_Group_Output.txt" 'Test For command line input, assign to variable if specified, if not use Default Set objArgs = WScript.Arguments.Unnamed If objArgs.Count = 0 Then InputFile = "./Users_by_Group_Input.txt" WScript.Echo "You didnt specify an input filename on the commandline," & vbNewLine &_ "The default is: " & InputFile & vbNewLine Else InputFile = WScript.Arguments.Item(0) End If Const ForWriting = 2 Set fso = CreateObject("Scripting.FileSystemObject") Set txtStreamOut = fso.OpenTextFile(OutputFile, ForWriting, True) searchType = InStr(InputFile, ".") If searchType = 0 Then WScript.Echo "The single computer you specified is: " & InputFile & vbNewLine getInfo InputFile Else WScript.Echo "You specified the file name: " & InputFile & vbNewLine If fso.FileExists(InputFile) Then Set txtStream = fso.OpenTextFile(InputFile) Do While Not (txtStream.AtEndOfStream) strComputer = txtStream.ReadLine getInfo strComputer Loop 'close input files Set txtStream = Nothing Set txtStreamOut = Nothing Else WScript.Echo "*****File Not Found, Try again*****" End If End if sub getInfo(fnComputer) Set colGroups = GetObject("WinNT://" & fnComputer & "") colGroups.Filter = Array("group") For Each objGroup In colGroups For Each objUser in objGroup.Members 'output needs to be in csv form Wscript.Echo fnComputer & "," & objGroup.Name & ","& objUser.Name txtStreamOut.WriteLine fnComputer & "," & objGroup.Name & ","& objUser.Name Next Next End sub
_____________________________
Have you searched
here
?
VBScript Fundamentals
My Site
Post #: 1
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
Post a VBScript
>> users by group
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI