net user command redirecting output
Hi Techies,
I run net user /domain, gives me the output in three columns as i have more than 1000 users. i need the output one record per line.
Advance thanks for the support.
Thanks
Alagar
May 12th, 2011 3:28am
Hello,
net user is limited in function. Have a look into dsquery or dsget commands, for example:
dsquery user DC=Contoso,DC=Com -o upn >c:\userupn.csv
will list all users of the domain contoso.com with the UPN name in an .csv file which you can open with Excel.
dsquery:
http://technet.microsoft.com/en-us/library/cc725702(WS.10).aspx
dsget:
http://technet.microsoft.com/en-us/library/cc732535(WS.10).aspx
Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2011 4:43am
Thanks for your reply.
I am getting the output with the double qoutes, it should give only the value because my another query using this as input to retrieve all the user information.
Thanks
Alagar
May 12th, 2011 8:56am
The DN's are enclosed in quotes because the contain embedded commas, and the quotes would be necessary if you are creating a csv file. Also, you can redirect the output to dsget to retrieve many other attributes. For example:
dsquery user "ou=West,dc=MyDomain,dc=com" -limit 0 | dsget user -samid -office -pager -company
Check help with "dsget user /?" for details. Does this help?
Richard Mueller - MVP Directory Services
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2011 11:02am
As Meinolf and Richard mentioned, it is better to use DSQEURY command.
What attributes are you looking for?
Also, you can format/filter the output using FIND command.
Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX
Blogs - http://blogs.sivarajan.com/
Articles - http://www.sivarajan.com/publications.html
Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
This posting is provided AS IS with no warranties,and confers no rights.
May 12th, 2011 7:02pm
Hi,
Thanks for the reply
i am able to get the output samid's but i need only the value not with the double quotes.
Alagar
Free Windows Admin Tool Kit Click here and download it now
May 15th, 2011 5:03am
i resolved by combining two scripts
dsquery user -limit 1500 -o samid >c:\scripts\username-x.txt
Get-Content C:\Scripts\username-x.txt | ForEach-Object { $_ -replace '"', "" } | Set-Content C:\Scripts\username.txt
Thanks
Alagar
May 15th, 2011 5:55am