Page 1 of 2 12>
Topic Options
#29829 - 2002-09-27 02:07 PM Extracting Username in TXT file
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Hello could someone give me some pointers for extracting all my usersnammes (SAM) into a text file?

Cheers

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#29830 - 2002-09-27 02:23 PM Re: Extracting Username in TXT file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
could you explain a little more...

where you have them now (where you want them to be extracted)?
_________________________
!

download KiXnet

Top
#29831 - 2002-09-27 02:32 PM Re: Extracting Username in TXT file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Run DumpDomain.exe
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#29832 - 2002-09-27 04:39 PM Re: Extracting Username in TXT file
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
I Just need to extract the Usernames that appear in User manager for domains into a Text file...

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#29833 - 2002-09-27 04:45 PM Re: Extracting Username in TXT file
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Steve,

I think you are looking for something like this..

code:
 BREAK ON
$userfile = "@CurDir\UserDump.xls"
IF Exist("$UserFile")
DEL "$UserFile"
ENDIF
$xl = CreateObject("Excel.application")
IF @error
EXIT
ENDIF
$rc = $xl.workbooks.add
$xl.cells(1, 1).value = "User ID"
$exlrow = 2
$crtheader = -1
$domain = GetObject("WinNT://@LDOMAIN")
$domain.filter = User,""
FOR EACH $user IN $domain
$user.getinfo()
? $user.name " ..."
$xl.cells($exlrow, 1).value = $user.name
FOR $i = 0 TO $user.propertycount
$property = $user.next
IF $property
IF $crtheader
$xl.cells(1, $i + 2).value = $property.name
ENDIF
$xl.cells($exlrow, $i + 2).value = $user.get($property.name)
ENDIF
NEXT
$exlrow = $exlrow + 1
$crtheader = 0

NEXT
$xl.rows("1:1").select
$xl.selection.font.bold = True
$xl.cells.select
$xl.range("R1").activate
$xl.cells.entirecolumn.autofit
$xl.rows("2:2").select
$xl.activewindow.freezepanes = True
$xl.activeworkbook.saveas("$UserFile")
$xl.quit
EXIT

HTH,

Kent

[ 27. September 2002, 16:46: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#29834 - 2002-09-27 04:46 PM Re: Extracting Username in TXT file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
code:
$DomainName="dss_test"
$domain = GetObject("WinNT://$DomainName,domain")

$domain.filter = "user",""

for each $user in $domain
? $user.name
next

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#29835 - 2002-09-27 04:47 PM Re: Extracting Username in TXT file
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see the groupmembers() UDF and do (domain users)

or this...

code:
break on

$domain = GetObject("WinNT://@ldomain") ;Connect to domain
IF $domain
$domain.filter="User",""
for each $user in $domain
? $user.name
next
ENDIF

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#29836 - 2002-09-27 04:48 PM Re: Extracting Username in TXT file
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
hah... a 3-peat
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#29837 - 2002-09-27 04:49 PM Re: Extracting Username in TXT file
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Steve,

Sorry about the excel stuff..

Doh!

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#29838 - 2002-09-27 05:17 PM Re: Extracting Username in TXT file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Excel is nice... you can browse it, sort it, save as .txt file, import to db...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#29839 - 2002-09-27 05:37 PM Re: Extracting Username in TXT file
Bob Deerinwater Offline
Starting to like KiXtart

Registered: 2002-05-05
Posts: 101
Loc: Covina California
If you have an Exchange Server the easy way is to extract the NT account list. You can take it to a csv file. And then bring it into excel.
Top
#29840 - 2002-09-27 05:45 PM Re: Extracting Username in TXT file
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Am I missing something I keep getting the following error...
code:
= User,""

Microsoft(R) Windows 98
(C)Copyright Microsoft Corp 1981-1999.

C:\WINDOWS>kix32 /d user.kix
Script error : unknown command !
$domain.filter = User,""


C:\WINDOWS>





_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#29841 - 2002-09-27 05:51 PM Re: Extracting Username in TXT file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Do you have ADSI installed on Win98? Run the script from a W2K computer.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#29842 - 2002-09-27 05:53 PM Re: Extracting Username in TXT file
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Sorry dont have a w2k workstation in the building, ADSI???
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#29843 - 2002-09-27 05:54 PM Re: Extracting Username in TXT file
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Further to Bob's response, you can also do an extract directly from Active Directory Users and computers, run MS-Access Reports from Hyena, etc.

[Smile]

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#29844 - 2002-09-27 05:56 PM Re: Extracting Username in TXT file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
http://www.microsoft.com/windows2000/techinfo/howitworks/activedirectory/adsilinks.asp

http://www.microsoft.com/ntserver/nts/downloads/other/ADSI25/default.asp
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#29845 - 2002-09-27 05:58 PM Re: Extracting Username in TXT file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
For the line:
$DomainName="dss_test"

did you replace the domain name with yours?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#29846 - 2002-09-27 06:08 PM Re: Extracting Username in TXT file
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Thanks chaps, downloaded ADSI for win98 and this works a treat, just one more question, how do I pipe this output on screen into say notepad or workpad????

Steve
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#29847 - 2002-09-27 06:12 PM Re: Extracting Username in TXT file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Check out the FAQ

Topic: File Input/Output Primer
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#29848 - 2002-09-27 06:43 PM Re: Extracting Username in TXT file
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Smashing, thanks for your help...

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1110 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.079 seconds in which 0.03 seconds were spent on a total of 17 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org