0

I executed the PowerShell script below 2 days ago and it returned 3 results. When I run the script today it does not return any results.

The script returns all changes made to the user's profile. Why does it no longer return the previous changes I saw when I ran the script previously?

PowerShell Script Used:

$mySiteUrl = "SharePointURL"
$adAccount = "domain\username"

#Region Load SharePoint Snapin
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#EndRegion

$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

if($profileManager.UserExists($adAccount))
{
    $userProfile = $profileManager.GetUserProfile($adAccount)

    $changes = $userProfile.GetChanges();

    foreach($change in $changes)
    {
        Write-Host "AccountName:"$change.AccountName "ChangeType:"$change.ChangeType "EventTime:"$change.EventTime "NewValue:"$change.NewValue "PropertyDescription:"$change.ProfileProperty.Description
    }
}
else
{
    Write-Host "Profile for user"$adAccount "cannot be found"
}

$site.Dispose()

The GetChanges method detailed here says "Returns all changes made to this user's data." Why are the changes no longer showing?

1 Answer 1

0

There is a job called "User Profile service application - user profile change cleanup". This job cleans up data that is 14 days old from User Profile change log. Migrates user rights from one user to another user, and migrates the user rights and removes that user from Active Directory Domain Services (AD DS). This is mainly used when the name of a user is changed in AD DS. The older user name is replaced by a new user name, and the older one is removed from AD DS.

If you want to change retention settings, see the Profilechangelog: Stsadm operation in Stsadm to Windows PowerShell mapping in SharePoint 2013.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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