What are the Various approaches to get all users from Active Directory to SharePoint 2013 List.

Posted on 2014-08-09
Last Modified: 2014-08-20
I would like to get the list of Users and their details like ManagerName, EMail, etc. from Corporate Active Directory to SharePoint List 2013
Question by:Maheshkumar K
    LVL 13

    Expert Comment

    Sounds as if you could use the user profile service. A built service that will replicate AD information and make it available to you via SharePoint.

    Author Comment

    by:Maheshkumar K
    I want to get these information out from AD to SharePoint Custon List
    LVL 13

    Accepted Solution

    You can use PowerShell to read the information from AD and write that information to a SharePoint custom list.  There are scripts available just for that purpose from TechNet.

    Author Comment

    by:Maheshkumar K
    Here is the working code:

    #Add SharePoint PowerShell SnapIn if not already added
        if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
            Add-PSSnapin "Microsoft.SharePoint.PowerShell"

        $site = new-object Microsoft.SharePoint.SPSite("http://ca1vmsp13dev:8005/");  
        $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);  
        $listName = "CustomUserProfileList"

        #Get UserProfileManager from the My Site Host Site context
        $ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)    
        $AllProfiles = $ProfileManager.GetEnumerator()  

        $WebUrl = "http://ca1vmsp13dev:8005/"
        $web = Get-SPWeb $webUrl
        $list = $web.Lists[$listName]

        foreach($profile in $AllProfiles)  
            $DisplayName = $profile.DisplayName  
            $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
            $ManagerName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::Manager].Value    

            $newItem = $list.AddItem()
            $newItem["EmployeeName"] = $DisplayName
            $newItem["EmployeeNTAccount"] = $AccountName
            $newItem["SupervisorNTAccount"] = $ManagerName

            #Here goes writing Logic to your SharePoint List + Check if account already existing in the SharePoint list then ignore writing.......
            write-host "---------------------------------------------------------"
            write-host "DisplayName for account ", $DisplayName
            write-host "Profile for account ", $AccountName
            write-host "Profile for account ", $ManagerName
            write-host "---------------------------------------------------------"

        write-host "Finished."
    LVL 13

    Expert Comment

    Glad that worked for you. Thanks for the acceptance.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
    Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
    This video teaches users how to migrate an existing Wordpress website to a new domain. provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now