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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.Fi leSystemOb ject")
Set MyFile = Myfso.CreateTextFile("c:\u serinfo.cs v", True)
'obtain your domain name
Set Wnet = wscript.CreateObject("WScr ipt.Networ k")
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&""""&.AccountExp irationDat e&""","
line=line&""""&.AutoUnlock Interval&" "","
line=line&""""&.BadPasswor dAttempts& ""","
line=line&""""&.Descriptio n&""","
line=line&""""&.FullName&" "","
line=line&""""&.HomeDirDri ve&""","
line=line&""""&.HomeDirect ory&""","
line=line&""""&.UserFlags& ""","
line=line&""""&.LockoutObs ervationIn terval&""" ,"
line=line&""""&.LoginHours &""","
line=line&""""&.LastLogin& ""","
line=line&""""&.LastLogoff &""","
line=line&""""&.LoginScrip t&""","
line=line&""""&.LoginWorks tations&"" ","
line=line&""""&.MinPasswor dAge&""","
line=line&""""&.MinPasswor dLength&"" ","
line=line&""""&.MaxBadPass wordsAllow ed&""","
line=line&""""&.MaxLogins& ""","
line=line&""""&.MaxPasswor dAge&""","
line=line&""""&.MaxStorage &""","
line=line&""""&.ObjectSid& ""","
line=line&""""&.Parameters &""","
line=line&""""&.PasswordAg e&""","
line=line&""""&.PasswordEx pirationDa te&""","
line=line&""""&.PasswordEx pired&""", "
line=line&""""&.PasswordHi storyLengt h&""","
line=line&""""&.PrimaryGro upID&""","
line=line&""""&.Profile
MyFile.WriteLine(line)
end with
next
MyFile.Close
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.Fi
Set MyFile = Myfso.CreateTextFile("c:\u
'obtain your domain name
Set Wnet = wscript.CreateObject("WScr
wscript.Echo "Userinfo for Domain:" & Wnet.UserDomain
' loop thru all users
set ogrp = GetObject("WinNT://"&WNet.
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.
line=""
line=line&""""&.name&""","
line=line&""""&.AccountExp
line=line&""""&.AutoUnlock
line=line&""""&.BadPasswor
line=line&""""&.Descriptio
line=line&""""&.FullName&"
line=line&""""&.HomeDirDri
line=line&""""&.HomeDirect
line=line&""""&.UserFlags&
line=line&""""&.LockoutObs
line=line&""""&.LoginHours
line=line&""""&.LastLogin&
line=line&""""&.LastLogoff
line=line&""""&.LoginScrip
line=line&""""&.LoginWorks
line=line&""""&.MinPasswor
line=line&""""&.MinPasswor
line=line&""""&.MaxBadPass
line=line&""""&.MaxLogins&
line=line&""""&.MaxPasswor
line=line&""""&.MaxStorage
line=line&""""&.ObjectSid&
line=line&""""&.Parameters
line=line&""""&.PasswordAg
line=line&""""&.PasswordEx
line=line&""""&.PasswordEx
line=line&""""&.PasswordHi
line=line&""""&.PrimaryGro
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
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