1

Is there a way to show/hide/Change the user profile properties based on the value of another user profile property

For Eg :

I have a custom Boolean user property and when the user checked the box i want to change the privacy policy of another property this doesn't need to be automatic

I am planning on writing a powershell and do it as a scheduled task which will check each hourly if the property is checked and if so it will change the privacy policy

But in the power shell i am unable to read the value of Boolean property when i am using Userprofile["SHowHide"].Value .Can someone please suggest me where i am going wrong ?

Thanks

2
  • What is the source of your User Profiles? Active Directory Domain Services or something else? If you use AD, have you Grant Active Directory Domain Services permissions for profile synchronization or is the syncronization account only allowed to read AD?
    – Benny Skogberg
    Sep 12, 2013 at 6:22
  • My main source is Active Directory and the account i am using has replicate permissions on the Actiev directory ,But the field i am using right now is a custom boolean property and will be filled by the users
    – Anil
    Sep 12, 2013 at 12:32

1 Answer 1

3

Disregarding what you are trying to do. The PowerShell to accomplish the read of the boolean field looks like this. (Tested in 2013)

$context = Get-SPServiceContext -Site http://mysite
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$up = $upm.GetUserProfile("DHT\Ruby")
$up["ShowHide"].Value

This returns True if its checked and False for uninitialized and unchecked.

Update the value in PowerShell with:

$up["ShowHide"].Value = $true
$up.Commit()
5
  • HI Mathew can you tell how we can change the privacy value of property using powershell..
    – Anil
    Sep 14, 2013 at 11:20
  • Does that work for you? If so can you vote me up? Sep 17, 2013 at 12:36
  • When I try this, I get the following error: New-Object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have 1e6a4921-c04c-4383-b0ba-dc4d0eda093d" At line:1 char:7 + $upm =New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) What am I missing?
    – William
    Nov 18, 2014 at 18:24
  • Do you have permission to use the User Profile Service? Nov 19, 2014 at 13:49
  • Alternate syntax for updating: $up.ShowHide = $true; $up.Commit()
    – Underverse
    Jan 17, 2018 at 1:21

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.