Manager Access to OneDrive after accidental removal of employee

Dustin V 96 Reputation points
2020-08-17T13:12:30.277+00:00

Because of an issue with the LDAP Filter. After the Mysite Cleanup Job Ran, All users in the Organization were slated for Deletion. Thus, granting Managers access to there employees OneDrives. I was able to fix the Deleted Status for all of the employees, but, how do I remove the managers as being Site Collection administrator for the employees?

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,941 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dustin V 96 Reputation points
    2020-08-17T21:01:25.897+00:00

    I think this will do it:
    $mysiteHostUrl = "https://mysites.mylrh.org"
    $mysite = Get-SPSite $mysiteHostUrl
    $context = [Microsoft.Office.Server.ServerContext]::GetContext($mysite)
    $upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

    $AllProfiles = $upm.GetEnumerator()
    foreach($profile in $AllProfiles) {
    if($profile.PersonalSite -ne $Null) {
    $site = new-object Microsoft.SharePoint.SPSite($profile.PersonalURL.AbsoluteUri)
    $site.SecondaryContact = $null
    write-host $profile.DisplayName "personal site re-permissioned successfully"
    }
    }

    $mysite.Dispose()


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.