?
Solved

Getting employee id value in windows 2008 powershell.

Posted on 2012-09-13
5
Medium Priority
?
1,533 Views
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:
EmployeeId
---------
e1
e2
e3
e4

$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
@{employeeid=e1},@{employeeid=e2}....

how do i get the values e1 ,e2 ,e3 stored in the variable,
0
Comment
Question by:AhmedAliShaik
  • 3
4 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 1500 total points
ID: 38394369
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.
0
 
LVL 2

Author Comment

by:AhmedAliShaik
ID: 38394383
Thanks Qlemo,

I will run and post you.
0
 
LVL 2

Author Comment

by:AhmedAliShaik
ID: 38396265
Qlemo Thanks a lot.
0
 
LVL 2

Author Closing Comment

by:AhmedAliShaik
ID: 38396277
Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
Loops Section Overview

850 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