How to import Specific user details from AD to csv.

Hi

We use windows 2008AD and I want to import user details from a particular OU
ie
Display name  and
Under Telephones : Pager
Any help much appreciated.

Thanks
lianne143Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pradeep DubeyConsultantCommented:
read below link if help

http://support.microsoft.com/kb/555636
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Haresh NikumbhSr. Tech leadCommented:
Import or Export??
0
Haresh NikumbhSr. Tech leadCommented:
Get-ADUser -Filter * -SearchBase "OU=Users,OU=Managed,DC=DOMAIN,DC=NET" -properties  telephoneNumber, pager, physicalDeliveryOfficeName  | select GivenName, surname, telephoneNumber, pager, physicalDeliveryOfficeName | export-csv -path d:\temp\test.txt -NoTypeInformation -Encoding "UTF8"
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

lianne143Author Commented:
Hi
I tried and iam getting the following error, I don't know if I made any error in the path

PS H:\> Get-ADUser -Filter * -SearchBase "OU=Marketing,OU=Targets,DC=DOMAIN,DC=local" -properties  telephoneNumber, pager, p
hysicalDeliveryOfficeName  | select GivenName, surname, telephoneNumber, pager, physicalDeliveryOfficeName | export-csv
-path D:\administrator\test.txt -NoTypeInformation -Encoding "UTF8"
Get-ADUser : The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-ADUser -Filter * -SearchBase "OU=Marketing,OU=Targets,DC=DOMAIN,DC=local" -prope ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-ADUser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS H:\>

Thanks
0
Alan GunnCommented:
Hi!
if it didn't recognise "get-aduser" you probably have to execute this line first.

import-module activedirectory

Open in new window


I assume you have put in your own searchbase. :-)

Cheers1
TRM

P.S.
That's a Cracking comand line Takecoffee!

Most impressed. :-)
0
Alan GunnCommented:
If you find Powershell exceeds your strangeness quota, ;-) you can also use dsquery *

dsquery * "OU=YourUsers,DC=yourCompany,DC=com" -filter "(objectcategory=user)" -limit 0 -attr displayName pager > details.txt

Open in new window


the resultant "details.txt" won't be comma delimited and you may have to do a "Text to column" inside Excel to split it up.

Normally "Fixed Width" is the best unless you have one or two users with excessively long display names.
If this is the case, I believe the columns in DSQuery * come out in the same order as they appear in the command line and so you can swap them around. :-)

TRM
0
Life1430Sr EngineerCommented:
dsquery user "OU=OUname,DC=domain,DC=local" -limit 0 | dsget user -display -email -pager>c:\Users.csv

Open in new window

0
lianne143Author Commented:
I tried: import-module activedirectory

PS H:\> import-module activedirectory
import-module : The specified module 'activedirectory' was not loaded because no valid module file was found in any
module directory.
At line:1 char:1
+ import-module activedirectory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (activedirectory:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

PS H:\>


After this I tried this I don't know where I am going wrong, it says about the path not sure.

PS H:\> Get-ADUser -Filter * -SearchBase "OU=Marketing,OU=Target,DC=DOMAIN,DC=local" -properties  telephoneNumber, pager, p
hysicalDeliveryOfficeName  | select GivenName, surname, telephoneNumber, pager, physicalDeliveryOfficeName | export-csv
Get-ADUser : The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-ADUser -Filter * -SearchBase "OU=Marketing,OU=Target,DC=DOMAIN,DC=local" -prope ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-ADUser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS H:\> -path D:\Temp\temp.txt -NoTypeInformation -Encoding "UTF8"
-path : The term '-path' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -path D:\Temp\temp.txt -NoTypeInformation -Encoding "UTF8"
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (-path:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS H:\>
0
Alan GunnCommented:
Hi!

The path error is because it cannot find the commandlet "Get-ADUser".

I verified this with the session below.
The path it is looking for is the path to the Get-aduser commandlet

This error is removed following the "import-module activedirectory" command

It turns out that this may not be available on all Windows 7 machines.


This link should help. :-)

You probably need the Remote System administration tools (RSAT)

http://blogs.msdn.com/b/rkramesh/archive/2012/01/17/how-to-add-active-directory-module-in-powershell-in-windows-7.aspx


C:\>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\> get-aduser
The term 'get-aduser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11
+ get-aduser <<<<
    + CategoryInfo          : ObjectNotFound: (get-aduser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\> import-module activedirectory
PS C:\> get-aduser

cmdlet Get-ADUser at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Filter:

Open in new window



If DSQuery is available on the machien you are using then that could be an option to complete the task.
0
Alan GunnCommented:
Do you think there would be a market amongst Windows server administrators for Tee-shirts with the motto-

"Where's my RSAT?"


;-)


TRM
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.