Powershell Get-ADUser


I have ten samid's taken into a text file.

I want to use the Get-ADUser with the -Identity parameter to take out some common values from all of the id's at once. Values such as Name,GivenName,Surname,Mail,UPN,Home Directory Path,Profile Path and put them together in a nice table format.

How do i do it together?

Any help is appreciated.

Thank you in advance

May 23rd, 2015 12:35am

How do i do it together?

If each samaccountname is in a separated text line and the file is *.TXT :

import-module activedirectory
Get-Content C:\Query.txt | % {Get-ADUser $_ -properties * } | FT Mail,Name,samaccountname -AutoSize

Otherwise copy the users into a CSV format and use this:

import-module activedirectory
Import-Csv C:\CSV.csv | % {Get-ADUser $_.name -properties * } | FT Name,Mail -AutoSize

Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2015 1:06am

Hi Mahdi,

Thank you for the prompt reply.

I was trying to use the forEach statement for this, along with the output in a Grid View. But each result generated a separate output window. Is there a way to integrate it in a single window ?

May 23rd, 2015 2:27am


you can used the below script also.

Get-Aduser -Filter * -Properties *|select name,@{n="memberof";e={[string]$_.memberof}},SamAccountName,PasswordExpired,PasswordLastSet,LastLogonDate,Enabled,DistinguishedName,DisplayName,GivenName,SurName|export-csv C:\output.csv

Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2015 9:25am

Hi Purvesh,

Your script is helpful too. But i needed one which would take input of samid's from a file as described by Mahdi. Thanks Again.

May 24th, 2015 1:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics