Skip to content
@JaredMeredith

@JaredMeredith

Learn. Share. Repeat.

  • Blog
  • About Me
  • Strengths Finder Top 5
    • Strengths Finder All 34
  • 16Peronalities
  • Builder Profile 10

Tag: Properties

Office, PowerShell, SharePoint, Windows

Export SharePoint Users and Properties from a specific Site Collection into a CSV file via PowerShell

08/10/2017 Jared Meredith

Wanted to provide a very helpful PowerShell snippet that I have used on multiple SharePoint farms to pull a list of users and their properties that can be exported out to a CSV file.

Simply update the snippet with your site collection URL and file path/name and you’ll be good to go!

$siteUrl = "http://yoursharepointsite"
$outputFile = "c:\filepath\yourfilehere.csv"

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$serviceContext = Get-SPServiceContext -Site $siteUrl
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $profileManager.GetEnumerator()

$fields = @(
            "SID",
            "ADGuid",
            "AccountName",
            "FirstName",
            "LastName",
            "PreferredName",
            "WorkPhone",
            "Office",
            "Department",
            "Title",
            "Manager",
            "AboutMe",
            "UserName",
            "SPS-Skills",
            "SPS-School",
            "SPS-Dotted-line",
            "SPS-Peers",
            "SPS-Responsibility",
            "SPS-PastProjects",
            "SPS-Interests",
            "SPS-SipAddress",
            "SPS-HireDate",
            "SPS-Location",
            "SPS-TimeZone",
            "SPS-StatusNotes",
            "Assistant",
            "WorkEmail",
            "SPS-ClaimID",
            "SPS-ClaimProviderID",
            "SPS-ClaimProviderType",
            "CellPhone",
            "Fax",
            "HomePhone",
            "PictureURL"
           )

$collection = @()

foreach ($profile in $profiles) {
   $user = "" | select $fields
   foreach ($field in $fields) {
     if($profile[$field].Property.IsMultivalued) {
       $user.$field = $profile[$field] -join "|"
     } else {
       $user.$field = $profile[$field].Value
     }
   }
   $collection += $user
}

$collection | Export-Csv $outputFile -NoTypeInformation
$collection | Out-GridView

Hope this helps, questions are welcome.

Help me out and share!

  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • More
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
Like Loading...
Tagged CSV, Excel, Export, Office 365, PowerShell, Properties, SharePoint, user profile

About Me

Jared Meredith

Jared Meredith

Verified Services

View Full Profile →

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 75 other subscribers

Why did I start the site…?

I started this site mainly as a place where I can put any gotchas and snafus I find along the way to better help the development community. I hope it helps as time goes on.

Questions? Comments?

If you have a question about a post then please leave a comment. I'll reply on the comment to keep all answers for everyone to see. If you have a private technical inquiry unrelated to any posts, please direct it to jared.meredith@live.com.

The Latest

  • Step-by-Step Guide to Deploy Azure Static Web Apps
  • Optimizing Enterprise Architecture Initiatives: Partnering Model and Essential Stages
  • Remember the 5-9, not just the 9-5!
  • Presentation Now Available: The Power of Cross-Platform Automated Web-Based Testing in CICD Pipelines
  • TLDR: Reflection + Pain = Progress

Categories

Create a website or blog at WordPress.com
  • Subscribe Subscribed
    • @JaredMeredith
    • Join 75 other subscribers
    • Already have a WordPress.com account? Log in now.
    • @JaredMeredith
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
%d