How to export Active Directory users, and save in a worksheet in excel.

My question is to know how to export Active Directory users, and save in a worksheet in excel. I used this command:

dsquery user domainroot |dsget user -display -office -loscr > C:\Arquiv.csv

But when it generates the table, it appears with the files out of order and messy.

You might start with learning the very basics of Powershell and even maybe learning how to use an internet search engine.

For Powershell I could recommend some of the links shared in this forum post: Beginner Sites and Tutorials.

First of all, this question was for those who know how to answer, if you do not know, I ask you not to talk nonsense.

I know exactly how to do what you asked but your question shows that you didn’t even spend any effort at all to find an answer by yourself. What you aksed has been asked and answered thousand times already. We do not write ready to use code on request here. If you have specific question to a particular piece of code you wrote you’re welcome to post this piece of code here and ask a question to that code and maybe to the errors you get.

Thank you,
Could you tell me where I can learn more?

I already did in my first answer. So you didn’t even read my answer completely. :-/

Check out these cmdlets

get-aduser

Export-CSV