Powershell Beginner

I've been using a cmdlet called ActiveRoles Management Shell for Active Directory and I am really able to pull some great AD data with it, but I am new to Powershell and have some questions.

For example, I can run Get-QADUser  -Enabled and it give me a very verbose output. Is there a way to pare this down any/reduce the fields it returns?? Also, when a command is preceded by a dash, what is that command called? And where can I find a list of commands that use that? Searching Google for "what is is called when a dash precedes a command" gets me nowhere. And get-command is not what I am looking for.

Thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale HarrisProfessional Services EngineerCommented:
I love beginners.  One of the best ways to learn is just to play with it.

Here's an article I wrote that is a "step 2" article.  I also link back to the step 1 as well.

It includes commands for the Active Roles Server Add-in.


In regards to your question, you can easily pull back whatever you want and put it into an array (list) for use later.


get-qaduser -enabled | select Name, DN

This will only bring back the Name and DN for display on the screen.

If I were you, I would go a step further and put it into an array.

$Users = get-qaduser -enabled

Now you can see what you can do with it by typing in the following command:

$Users | gm

GM is an alias for get-member, so either will work.  Basically it will show you all the properties/methods.  This list is very extensive, but not as extensive as pulling up your adsiedit.msc and getting the list of attributes available for a user.

It shows you that name is available.  So iterate through your list and show the names of each person:

$Users | foreach-object{$_.name}

You can also substitute foreach-object with the percentage symbol %, so it looks like this:

$Users | %{$_.name}

The $_.property signifies "Whatever you started with, bring it over to the right and use it as an object".

The pipeline is really important to understand early so I recommend the following way to think about it:

You start out with a bunch of users.  We will call this our marathon.  Now, you want to filter out some people in your search.  So you do a search for every user with an expired password.  This would be like asking for every person in the marathon that's a male.

It would look like this:

$Users | ?{$_.passwordisexpired}

Now let's see who's name starts with an "H", so it would be similar to asking for everyone that is under 30.

$Users | ?{$_.passwordisexpired} | ?{$_.name.startswith("H")}

So now we have a list of people that made it to the end outputted to the screen when we run this.  Every user that their password is expired and starts with an H.  Or every person in the marathon that is a male under 30.

If you want to store that to a different list, you can simply add a $RefinedUserList = to the beginning to look like this:

$RefinedUserList = $Users | ?{$_.passwordisexpired} | ?{$_.name.startswith("H")}

You won't get an output, but when you do a "$RefinedUserList.count" it will tell you how many users got into the list.

Then you can see the list by typing in $RefinedUserList

Then you can output that to a text file by typing in $RefinedUserList > Users.txt

This will create a Users.txt file with that list in your directory you're working from.

Try to work from C:\scripts as your main working script directory.

Good luck and happy scripting!

Dale Harris
Dale HarrisProfessional Services EngineerCommented:
Oh and -commands are called parameters.

You have a cmdlet (example: Get-WMIObject) with a parameter (-computer) with an argument (


get-wmiobject Win32_BIOS -computer


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DarthRaterAuthor Commented:
0_o....good lord. Best answer ever! Thank you!
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
http:#a37316250 is the reason why you do not get anywhere with get-command or Google search, if just search for the parameter name ;-).
You need to view the cmdlet itself for which parameters it allows. get-help get-wmiobject   for example.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.