RE: Simple AD shell script - discover usernames
- From: "Farai Alleyne" <FaraiAlleyne@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Aug 2005 13:23:01 -0700
I'm trying to do something similar - except the reverse - i'm trying to get
the full name of a user based on their username using dsquery (or any other
AD tool possible).
thanks.
"Martin Jones" wrote:
> Hi,
> I'm trying to create a script that takes a txt list of users full names, and
> does a dsquery to find their username.
> Txt file layout :
> smith, john
> jones, taffy
> ...etc
>
> Script:
>
> REM Pass Users Full Name to this batch (format: surname, firstname)
> REM First create input text file: C:\Temp\userlist.txt
>
>
> Rem **** Clear temp variables
>
> set FullName=
>
>
> Rem **** Extract Name
>
> For /f "tokens=2 delims=[" %%a in ('Findstr /I /C:"[" C:\Temp\userlist.txt')
> do (set mess=%%a)
> For /f "tokens=1 delims=]" %%b in ("%mess%") do (set FullName=%%b)
>
>
>
>
> Rem **** Check if Output file exists and create if not
>
> IF EXIST C:\temp\output.txt Goto Output
>
> Echo Full Name,Username >C:\temp\output.txt
>
>
>
>
> :Output
>
> Rem **** Run Dsquery
>
> dsquery user -name "%FullName%" | dsget samid >>C:\Temp\output.TXT
>
> --------------------------------------------------------------------------
>
> Script is salvaged from an old IP discovery script I part-wrote a while ago.
> Obviously its not working, and I suspect its poor use of tokens/delims.
>
> Any ideas/help very welcome.
> Thanks in advance.
.
- Follow-Ups:
- Re: Simple AD shell script - discover usernames
- From: Marty List
- Re: Simple AD shell script - discover usernames
- References:
- Simple AD shell script - discover usernames
- From: Martin Jones
- Simple AD shell script - discover usernames
- Prev by Date: Re: What's \\hostname\IPC$ for?
- Next by Date: Re: scripting vs. batch files?
- Previous by thread: Re: Simple AD shell script - discover usernames
- Next by thread: Re: Simple AD shell script - discover usernames
- Index(es):
Relevant Pages
|
Loading