• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 46
  • Last Modified:

PowerShell

I am working on PowerShell to get members of security group and export to CSV with AD attributes like name, email, department, employeID, title    
The PS below just gets the name and leaves the other fields.

Get-ADGroupMember -Identity "Domain" | Select-Object -properties name,mail,tittle,department,office |Export-csv C:\temp\Members.csv
0
Debrata 1
Asked:
Debrata 1
  • 6
  • 4
  • 3
1 Solution
 
Travis MartinezSmoke JumperCommented:
I believe you need to pipe the command to "get-aduser" and select the properties from there.  I used the following to test with:

Get-ADGroupMember -identity "Domain Users" | get-aduser -Filter * -properties Displayname, emailaddress, title, department, office | select displayname, emailaddress, title, department, office

Open in new window


Obviously the "Domain Users" would be replaced with "MCP-BCAST-PARKS" and add the export-csv to the end.
0
 
Debrata 1Author Commented:
Get-ADUser : Cannot find an object with identity: 'John, Smith"

I am getting the above error. I think the Get-ADGroupMember does not get the aduser ,rather it gets the first name and last name that's why we can not use Get-ADUser
0
 
Travis MartinezSmoke JumperCommented:
You're right, I broke the command before it finished completely but I was able to get the information you were looking for.  I'll work on it.
0
WEBINAR: 10 Easy Ways to Lose a Password

Join us on June 27th at 8 am PDT to learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees. We'll cover the importance of multi-factor authentication and how these solutions can better protect your business!

 
ITguy565Commented:
Try this
Get-ADGroupMember -Identity "domain users" |Get-ADUser -property Displayname, emailaddress, title, department, office | select displayname, emailaddress, title, department, office

Open in new window

1
 
Travis MartinezSmoke JumperCommented:
What ITguy565 put down worked for me.
0
 
Debrata 1Author Commented:
Same error, I don't think we can use Get-ADUser

Get-ADUser : Cannot find an object with identity: 'John, Smith"
0
 
ITguy565Commented:
Can you paste a screenshot of what you are getting when executing my code?
0
 
ITguy565Commented:
I just tested it and it is working at least here.. are you running admin powershell prompt?

I am also assuming that you are using

import-module activedirectory
0
 
ITguy565Commented:
Try this

Get-ADGroupMember -Identity "domain users" -EA SilentlyContinue |Get-ADUser -property Displayname, emailaddress, title, department, office | select displayname, emailaddress, title, department, office

Open in new window

0
 
ITguy565Commented:
@ALif Mehari

Did it work for you?
0
 
Debrata 1Author Commented:
Apologies, It's working now. I just made a mistake of the CSV path that i am looking at and the error is for some of the users not for all.
0
 
ITguy565Commented:
This should give you your export as well.

Get-ADGroupMember -Identity "domain users" -EA SilentlyContinue |Get-ADUser -property Displayname, emailaddress, title, department, office | select displayname, emailaddress, title, department, office |Export-csv C:\temp\Members.csv

Open in new window

0
 
Travis MartinezSmoke JumperCommented:
ITguy565 Had the correct command and output
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now