?
Solved

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

Posted on 2016-11-23
2
Medium Priority
?
88 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
[X]
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
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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 …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

752 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