Link to home
Start Free TrialLog in
Avatar of jacks3335
jacks3335

asked on

Exporting usrmgr fields

I want to export/copy the fields in usrmgr to a text/csv file for upload into a database.  Under usrmgr there is no export and you can't highlight and right click.  How can I copy these entries into a file?
ASKER CERTIFIED SOLUTION
Avatar of omalakai
omalakai

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CosmoNut
CosmoNut

As posted in your repeat, NT4 Resource kit, and 2k pro resource kit included a utility called "adduser.exe" for importing and exporting user accounts to/from a comma delim text file.
On a DC open a command prompt and run
net users >c:\userlist.txt
this creates a file of all the users in your organisation.
next edit the file using a text editor and get each user on a line, so that the command
net users username >>userprops.txt
is run for each user.
this will give you the following information for each user in the userprops.txt file:
User name  ,Full Name  ,Comment ,User's comment,Country code  ,Account active,Account expires  ,,Password last set,Password expires ,Password changeable ,Password required,User may change password  ,,Workstations allowed,Logon script  ,User profile  ,Home directory,Last logon ,,Logon hours allowed ,,Local Group Memberships,  ,Global Group memberships

You will find that notepad is probably not up to the task of quickly editing such a file, I used textpad, as you can do search and replace on regular expressions, if you needed to automate this a perl program could quickly be set up to automate this.
Just a freebie solution....
You can use the Windows script below to list the users for your domain and write their properties to a csv text file. As not all properties are supported by NT4.0, leave the on error clause, so the script does not crash when certain properties are not found. (I assume you have the latest Microsoft DCOMs and ADSI installed to get to the objects used)
Just save the code below as userinfo.vbs and run it from the command prompt  
as: cscript userinfo.vbs
'
' userinfo.vbs - list user account details for your domain
'
on error resume next
'create output csv file
Set Myfso = CreateObject("Scripting.FileSystemObject")
Set MyFile = Myfso.CreateTextFile("c:\userinfo.csv", True)
'obtain your domain name
Set Wnet = wscript.CreateObject("WScript.Network")
wscript.Echo "Userinfo for Domain:" & Wnet.UserDomain
' loop thru all users
set ogrp = GetObject("WinNT://"&WNet.UserDomain&"/Users")
set ombr = ogrp.members()
' get all properties for a user (delete the ones you dont need)
for each ousr in ombr
 with ousr
 wscript.echo("user="&ousr.name)
     line=""
     line=line&""""&.name&""","
     line=line&""""&.AccountExpirationDate&""","
     line=line&""""&.AutoUnlockInterval&""","
     line=line&""""&.BadPasswordAttempts&""","
     line=line&""""&.Description&""","
     line=line&""""&.FullName&""","
     line=line&""""&.HomeDirDrive&""","
     line=line&""""&.HomeDirectory&""","
     line=line&""""&.UserFlags&""","
     line=line&""""&.LockoutObservationInterval&""","
     line=line&""""&.LoginHours&""","
     line=line&""""&.LastLogin&""","
     line=line&""""&.LastLogoff&""","
     line=line&""""&.LoginScript&""","
     line=line&""""&.LoginWorkstations&""","
     line=line&""""&.MinPasswordAge&""","
     line=line&""""&.MinPasswordLength&""","
     line=line&""""&.MaxBadPasswordsAllowed&""","
     line=line&""""&.MaxLogins&""","
     line=line&""""&.MaxPasswordAge&""","
     line=line&""""&.MaxStorage&""","
     line=line&""""&.ObjectSid&""","
     line=line&""""&.Parameters&""","
     line=line&""""&.PasswordAge&""","
     line=line&""""&.PasswordExpirationDate&""","
     line=line&""""&.PasswordExpired&""","
     line=line&""""&.PasswordHistoryLength&""","
     line=line&""""&.PrimaryGroupID&""","
     line=line&""""&.Profile
     MyFile.WriteLine(line)
  end with
next
  MyFile.Close

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
jacks3335,

No comment has been added lately (207 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question
is:

to be PAQ'd, with points forfeited.

Please leave any comments here within the next SEVEN days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Renots
EE Cleanup Volunteer