[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
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
?
105 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

Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

650 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