Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Powershell: Add EmployeeID to existing Get-ADUser and Get-ADGroup script with multiple lines for each user

Posted on 2016-11-23
2
49 Views
Last Modified: 2016-11-23
This is the working script that I have. I would like to add the EmployeeID attribute for each user but am having trouble with the syntax. The output shows the user and the group name, but does not show the EmployeeID.

Import-Module Activedirectory
Get-ADUser -Filter * -Properties DisplayName,memberof,EmployeeID | % {
 $Name = $_.DisplayName
 $EmployeeID = $_.EmployeeID
  $_.memberof | Get-ADGroup | Select @{N="User";E={$Name}},Name
 } | Export-Csv C:\Reports\Testing\GroupsMultipleLines2.csv -nti

Open in new window

0
Comment
Question by:Intelli-Seeker
2 Comments
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 41899346
That's because you don't create a calculated property for EmployeeID:
Import-Module Activedirectory
Get-ADUser -Filter * -Properties DisplayName, MemberOf, EmployeeID | % {
	$ADUser = $_
	$_.MemberOf | Get-ADGroup | Select-Object @{N="User"; E={$ADUser.DisplayName}}, @{N="EmployeeID"; E={$ADUser.EmployeeID}}, Name
 } | Export-Csv C:\Reports\Testing\GroupsMultipleLines2.csv -nti

Open in new window

1
 

Author Closing Comment

by:Intelli-Seeker
ID: 41899357
This is perfect and exactly what our Supervisors need for auditing their users. Thanks a million!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This article runs through the process of deploying a single EXE application selectively to a group of user.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

839 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