SharePoint Server: Purge Cached Access


As content is migrated from [SharePoint Server] to [SharePoint Online], the sites are often moved incrementally. But post-migration, not everyone uses their new links day-one. There are enough people still trying to use their old SPS bookmarks, so I needed to purge legacy site access. This includes the site collection user cache and forces everyone to update their bookmarks…

  • E.g.,
    • List accounts to be ignored.
    • List target SPS site collection.
    • Iterate target user accounts and remove.
      • Ignore system and admin accounts.
$listOf = @()
$listOf += "Admin Install"
$listOf += "Admin Service"
$listOf += "SHAREPOINT\system"

$targetSite = "https://onpremise.contoso.com/"

Get-SPUser -Web $targetSite -Limit All | % {
    [System.String] $lName = $_.LoginName
    [System.String] $dName = $_.DisplayName

    if ($listOf.Contains($dName) -eq $false) {
        Remove-SPUser $lName -Web $targetSite -Confirm:$false
    }
}

NOTE: Each removal requires confirmation, but I would rather not click ‘Yes’ a few hundred times. -Confirm:$false mutes that prompt message.


Conclusion:
People are creatures of habit. Even with proper communication of the migration, not everyone will be responsive. That is why removing their access post-migration is an important step. When they get an “Access Denied” message, they’ll likely contact support OR respond to earlier communications…

“With each day, I give thanks for the blessings of life—the blessings of another day and the chance to do something with it. Something good. Something significant. Something helpful. No matter how small it might seem. I want to keep making a difference.”

Mamie Till-Mobley

#blacklivesmatter

Leave a comment