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?