SharePoint - Delete Manager from UserProfile

Today's task revolved around removing the Manager I set when testing the profile pages on the my site portal. I had set the manager on a service account so it had to be removed to stop appearing as a colleague to team members and potentially exposing a security risk in giving away the service account username.

Setting it is possible directly from the Organisational View page that comes as part of the site template. There is a link called "Set My Manager", which allows you to set the current UserProfile's manager. Once set though I wanted to remove this profile.

Unfortunately, there is no way for the user to remove their manager only set the manager. So only an administrator can remove the manager.

Initially, being a powershell fanatic. I tried to remove the manager using the object model using the following powershell commands:

$site = get-spsite http://localhost
$context = Get-SPServiceContext $site
$mgr = new-object "Microsoft.Office.Server.UserProfiles.UserProfileManager" -ArgumentList $context
$enum = $mgr.GetEnumerator()
do {$enum.MoveNext();$usr = $enum.Current} until ($enum.Current["AccountName"] = "domain\username")

The following commands failed to remove the manager from the UserProfile:

$usr.Parent = $null     //Throws exception: "Setting Parent of a UserProfile is not allowed via OM."

$usr.Properties.RemovePropertyByName("Manager") // Throws exception: "Property update's Stored Procedure call returned an error. Error Code: 4. Errors removing P propert"

Funny, most things can be done easier through powershell. But in this instance Central Admin did the trick!

Central Administration -> Application Management -> Manage Service Applications -> User Profile Service (click Manager) -> Manager User Profiles.

Using "Find profile" enter the account name, and select "Edit My Profile" from the drop down when selecting the account. From this page you can change the manager and set it to nothing and click "Save and Close" to apply the new value.

That's it! There is no single way to manage Sharepoint, you need to know all the tools available as some have strengths over others. Central Admin wins over powershell on this one for user-friendlyness (it just worked).


Popular posts from this blog

Change Password in Windows Server 2012

Microsoft Flow - Renaming Files in SharePoint Online using Flow

SharePoint Set Locale Region on All Web Applications and Site Collections