Re: Simple AD shell script - discover usernames

Tech-Archive recommends: Speed Up your PC by fixing your registry



for /f "tokens=*" %a in (<textfile of usernames>) do dsquery user -name
"%a" | dsget user -samid

If you're intending in placing the command above in a batch file don't
forget to replace the single percent (%a) with double percent (%%a) in
both cases.

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l

Martin Jones wrote:
> Hi,
> Ok, one of my users passed me a txt list of users:
>
> smith, john
> jones, bob
> etc ...
>
> Which coincides with our "Name" convention in AD.
> To do what the user wants me to do, I need to convert those "surname,
> firstname"
> into their AD username.
>
> The Command:
> dsquery user -name "smith, john" | dsget user -samid
>
> at prompt returns:
> samid
> SMITHJ
> dsget succeeded
>
> now I could type that command for each entry in the txt file (200+),
> but obviously want to automate it, so it finds the corresponding
> username for each entry.
> All I want is the SMITHJ appending to the "smith, john" in the text
> file so my txt file looks like:
> smith, john SMITHJ
> jones, bob JONESB
>
> Then I can pull into Excel and populate our printer address books.
>
> Even simpler : User passed me a txt list of names, which I need to
> batch convert to AD usernames.
>
> Hope that clears it up, Thanks for the help so far.


.



Relevant Pages

  • Re: i want to add a promt to a batch command.
    ... When you want to add a prompt to a BATCH file you would use the set ... so if you wanted to name your variable "Username" you would have ... set is the command ...
    (microsoft.public.windows.server.scripting)
  • Re: Creating a batch file
    ... Are you looking for a command that will do this? ... > a windows XP machine. ... > have to change the username in the batch file, ... > sure where it was the username or password, ...
    (microsoft.public.win2000.printing)
  • Re: Batch File to connect to a pc
    ... > a windows XP machine. ... > What is the format in which the command should be?? ... > have to change the username in the batch file, ... > sure where it was the username or password, ...
    (microsoft.public.win2000.general)
  • Creating a batch file
    ... a windows XP machine. ... What is the format in which the command should be?? ... have to change the username in the batch file, ... sure where it was the username or password, ...
    (microsoft.public.win2000.printing)
  • Batch File to connect to a pc
    ... a windows XP machine. ... What is the format in which the command should be?? ... have to change the username in the batch file, ... sure where it was the username or password, ...
    (microsoft.public.win2000.general)