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.
