Scenario:
I was asked by my client to export User Profile data into Excel.
Solution:
Answer was Powershell. I googled and found a good script to start with, I just added few more things and tested it. Here's the script
Code:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$siteUrl = "http://sp2010"
$outputFile = "C:\UserProfiles.csv"
$serviceContext = Get-SPServiceContext -Site $siteUrl
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $profileManager.GetEnumerator()
Write-Host "Exporting profiles"
$collection = @()
foreach ($profile in $profiles) {
$profileData = "" | select "AccountName","FirstName", "LastName","PreferredName","WorkPhone"
$profileData.AccountName = $profile["AccountName"].Value
$profileData.FirstName = $profile["FirstName"].Value
$profileData.LastName = $profile["LastName"].Value
$profileData.PreferredName = $profile["PreferredName"].Value
$profileData.WorkPhone = $profile["WorkPhone"].Value
$collection += $profileData
}
$collection | Export-Csv $outputFile -NoTypeInformationArticle:User Profile export




4 comments:
Woked G8 article
I need to export all user profiles. With all the information, so I can compare any changes. Is there a script that does that?
Is there a way too export all user profiles with all attributes, so I can compare, if there are any changes
It doesn't do any comparison - only export
Post a Comment