Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to query the groups a NT domain user belongs to from an excel cvs

Status
Not open for further replies.

fkane17

Technical User
Jul 9, 2003
5
0
0
US
dim dom,un,ls,user
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshEnvironment = WshShell.Environment("Process")
dom = WshEnvironment.item("USERDOMAIN")
un = WshEnvironment.item("USERNAME")
ls = right(WshEnvironment.item("LOGONSERVER"),len(WshEnvironment.item("LOGONSERVER")) -2)


Set user = GetObject("WinNT://" & dom & "/" & ls & "/" & un)

WScript.Echo "Login Script: " & User.LoginScript
WScript.Echo "Profile: " & User.Profile
WScript.Echo "PasswordExpirationDate: " & User.PasswordExpirationDate
WScript.Echo "HomeDirectory: " & User.HomeDirectory

WScript.Echo "Groups: "

for each Group in User.Groups
WScript.Echo vbtab & Group.name
next

WScript.Echo "LastFailedLogin: " & User.LastFailedLogin

I wrote the code above to check the groupmembership for a user on a particular domain.
I want to check the groupmembership of 300 users.

I have an excel spreadsheep which contain the list of users and the domain they are member.

I am new to wsh scripting. How to I have the script read from the excel file the user id the domain and write the group the user belongs to ?
 
open the csv file as a text stream, or open it as a recordset using ADO.
or put the above code into an excel macro and run it from within excel. all the above code will work within VBA. output your results to additional rows/col in the excel spreadsheet/csv file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top