2

I am using SharePoint 2013 on-prem.

In the User Profile Service Application > Manage user properties, the properties can be hidden from users my site by unchecking the check boxes under "display settings" of the user property. We want to hide the "Assistant" property i.e.

I can do it with the Central Admin GUI, but I am struggling to do so with PowerShell commands. I have googled and found a property called "IsVisibleOnEditor" which can be used, but I am not able to find this property.

The code I use is this:

$webApp = Get-SPWebApplication -Identity http://dev.mysite.com:81/
$site = Get-SPSite $webApp.Url;
$context = Get-SPServiceContext $site;

$upConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context);
$profilePropertyManager = $upConfigManager.ProfilePropertyManager;
$coreprofilePropertyManager = $profilePropertyManager.GetCoreProperties();
$userProfileTypeProperties = $profilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User);
$userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($context);
$userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User));
$userProfileProperties = $userProfile.Properties;


foreach($p in $userProfileProperties)
{               

    if($p.Name -eq "Assistant")
    {

         if($p.IsUserEditable -eq $true)
         {
            $p.IsUserEditable = $false; 
            $p.Commit();
         }

       #------------------------------------#
       #Here I thought I could use $p.IsVisibleOnEditor, but it does not exist 

    }
}

What am I doing wrong here?

1 Answer 1

1

After smacking my head around for a long time, I finally figured it out.

Keeping in mind the code in the opening post, this is what I added:

$p.TypeProperty.IsVisibleOnEditor = $false; $p.TypeProperty.IsVisibleOnViewer = $false;

After figuring this part out, I still saw no changes because the fields where not updating. I found out that I had to update the type property like this:

$p.TypeProperty.Commit()

Your Answer

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

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