Getting employee id value in windows 2008 powershell.

Posted on 2012-09-13
Last Modified: 2012-09-13
I want the give the command as a input to variable in a script

The output is in the below format:

$empid = Get-Adgroup -identity groupname | get-adgroupmember | get-aduser -properties * |select employeeid

Open in new window

when i check the output using write-host $empid i am getting

how do i get the values e1 ,e2 ,e3 stored in the variable,
Question by:AhmedAliShaik
    LVL 67

    Accepted Solution

    That is because you have multiple results, and so they are stored in a hash table to maintain the properties. You need to convert each EmployeeID into a string first. select-object can do that for you:
    $empid = Get-Adgroup -identity groupname | get-adgroupmember | get-aduser -properties * |select -ExpandProperty employeeid

    Open in new window

    BTW: Not sure about that, but get-aduser EmployeeID should be better than using * here.
    LVL 2

    Author Comment

    Thanks Qlemo,

    I will run and post you.
    LVL 2

    Author Comment

    Qlemo Thanks a lot.
    LVL 2

    Author Closing Comment


    Featured Post

    Shouldn't all users have the same email signature?

    You wouldn't let your users design their own business cards, would you? So, why do you let them design their own email signatures? Think of the damage they could be doing to your brand reputation! Choose the easy way to manage set up and add email signatures for all users.

    Join & Write a Comment

    This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
    This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now