What you’re asking for is a very common tasks and has been asked a thousand times already. And has been answered a thousand times already.
Please use your favorite search engine to search for examples for tasks like this. I’m sure you will find more than enough to get you started. Some good sources for inspiration would be either this forum here or StackOverflow or maybe the PowerShell Gallery.
If you have a particular piece of code you wrote yourself and have problems with it you’re very welcome to post this here along with a description what problem you have with it and we will be happy to try to help you.
Well, i have phrased this in Google and i don’t seem to comprehend or get the result i want. I also have a learning difficulty, so trying my best too in comprehending this what may be a simple task to most people
Any leads to examples of what i wish to achieve is greatly appreciated.
That sounds like you already tried something and you’ve got some results at least. Even if it’s not exactly what you want you should start playing around with it to figure out how to use the commands you found.
You should rather start with learning the very basics of PowerShell first before you move on to some more advanced tasks. That will save you from a lot of wasted time and frustration. It’s impossible to learn a complex technology like a scripting language by guessing or by piecing together some arbitrary snippets of code you found on the internet. And you will not learn it when we write the code for you.
And … as I already wrote … if you have some self written code you’ve got stuck with you should post this code here (formatted as code please) and we will try to help you.
That’s what some of us are here for. But we do not deliver ready to use code or solutions on request. You’re expected to do the basic research on your own and come up with AT LEAST A FEW LINES OF CODE!!! … when you post code please format it as code using the “preformatted text” icon ( </> )
To get you started you can read the help for the following cmdlets:
You should always read the help completely including the examples to learn how to use them.
That’s the same for all of us. Nevertheless you have to keep trying. That’s how we all do it.
There’s is little to no chance for you to find something perfectly fitting for your requirements. So you take something what provides you with a result some kind of near to what you’re looking for and start to tweak it. If you get stuck in this process PLEASE POST YOUR CODE and I’m sure we will be able to help you.
I understand good practice is always the ideal recipe.
In all honesty, I don’t find this method to be greatly encouraging at times. In fact I find it off-putting. As I’m wasting time in trying to get an output that can only be changed completely to what I started with and then still not getting the syntax and parameters used in what I need to achieve.
What other method would you prefer? At the moment you did not show any effort at all. You asked for others to do your job. I posted the basic cmdlets you need to accomplish this task. Start with reading the help. There are examples included you can use to start to play with in your environment.
As I already said, there is no easy way to learn a complex technology like PowerShell. The process of learning the basics will teach you how to find the right cmdlet and how to find and how to read the help as well.
This is what I have come up with. I welcome feedback and improvements from anyone.
First, some warnings, this command could be dangerous to the performance of your AD environment. It could run amok. I don’t warranty this code but I do strongly believe in it’s abilities. If run in a large corporate environment it could take quite a while and bog down the availability of domain authentication resources. There are additions that could be made to this command to send it only to one server (if you have a dedicated DC that does that kind of thing) or to limit it by the members in a group. As written, it will export every user in the domain that is logged into when executed.
The command will retrieve all of the users in the active domain, return the specified properties (in addition to the normal ones), filters down to only the desired properties and then exports the list to a CSV named users.csv.
The properties selected were what I believe to be the best matches based on your request. There are more options. I found a list at this page. You would need to use the names from the column on the right to replace or add to what was provided above if you want to change any of them out.
My bill - Please watch the video I recommended above if you need to use PS as part of your career. I understand that you learn best by example, this video is just example after example. It will get you moving in the right direction and then give you the ability to show up here asking why your specific code doesn’t do what you want.