2

I'm trying to list user information from the whole site collection but lot of the properties are just blank:

Get-SPUser -Web https://sp.contoso.com/sites/test -Limit All | Select UserLogin, PreferredName, FirstName, LastName, WorkPhone, Email | Export-Csv C:\list.csv

I used this article to check the required user info, but it seems like it does not work: https://technet.microsoft.com/en-us/library/hh147510.aspx

What I'm trying to get:

  • Username
  • Display Name
  • First Name
  • Last Name
  • Phone number
  • Email
  • SharePoint group

Best Regards Artur

0

You can try the following script:

          function GetSPWebUsers($SiteCollectionURL) 
    { 
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 
        $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) 
        $web = $site.openweb() 
        $siteUsers = $web.SiteUsers 

        foreach($user in $siteUsers) 
        {        
            Write-Host " ------------------------------------- " 
            Write-Host "Site Collection URL:", $SiteCollectionURL 
            if($user.IsSiteAdmin -eq $true) 
            { 
                Write-Host "ADMIN: ", $user.LoginName 
            } 
            else 
            { 
                Write-Host "USER: ", $user.LoginName 
            } 
            Write-Host " ------------------------------------- " 
        }    
        $web.Dispose() 
        $site.Dispose() 
    } 
1
  • Thank you for this script! It helped me diagnose the root problem. The farm I'm working on has very weird configuration and not all data is copied from AD to SP user profile. I will have to go with different approach: 1. extract user emails from SP site collection; 2. based on those emails, I will try to find the users in AD; 3. and then import all other required information, like phone number Sep 12 '17 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.