In this article we will be seeing how to Set Privacy Policies for User Profile Properties in SharePoint 2010 using PowerShell.
Introduction:
Microsoft SharePoint Server 2010 enables you to set privacy policies on user profile properties.
The Default Privacy policy limits the visibility of properties, users' My Documents, and other My Site content to:
Member name Description
Public . Privacy level gives visibility of users' profile properties, and other My Site content, to everyone.
Contacts . Privacy level limits the visibility of users' profile properties, and other My Site content, to my colleagues.
Organization Privacy level limits the visibility of users' profile properties, and other My Site content, to my workgroup.
Manager . Privacy level limits the visibility of users' profile properties, and other My Site content, to my manager and me.
Private . Privacy level limits the visibility of users' profile properties, and other My Site content, to me only.
NotSet . Privacy level is not set.
Note: For more information on PrivacyPolicy Enumeration please refer http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.privacypolicy.aspx.
Set Privacy Policies for User Profile Properties in SharePoint 2010
We can set Privacy Policies for User Profile Properties in SharePoint 2010 from Central Administration.
Go to Central Administration => Application Management => Manage Service Applications => User Profile Service Application.
Click on Manage User Properties
Select the property and then click on Edit to modify the property.
Automation: Set Privacy Policies for User Profile Properties in SharePoint 2010 using PowerShell
Here we will be seeing how to set Privacy Policies for User Profile Properties in SharePoint 2010 using PowerShell.
Steps Involved:
Create the input XML file which contains the inputs for setting Privacy Policies.
Create ps1 file which contains the script for setting Privacy Policies.
SetPrivacyPolicies.xml
<?xml version="1.0" encoding="utf-8" ?>
<PrivacyPolicies>
<URL>http://serverName06:8080/</URL>
<Property Name="Sample1" Privacy="Contacts" PrivacyPolicy="mandatory"></Property>
<Property Name="Sample2" Privacy="Public" PrivacyPolicy="disabled"></Property>
<Property Name="Sample3" Privacy="Manager" PrivacyPolicy="OptIn"></Property>
</PrivacyPolicies>
SetPrivacyPolicies.ps1
#----------------Get the xml file---------------------------------------------------------------
[xml]$xmlData=Get-Content "C:\Users\Desktop\ContentSources\SetPrivacyPolicies.xml"
#----------------Set Privacy Policies for User Profile properties--------------------------------------------- function SetPrivacyPolicies() {
$site = Get-SPSite $xmlData.PrivacyPolicies.URL
$context = Get-SPServiceContext($site)
$psm = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($context)
$ps
=$psm.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User))
$pspm = $ps.Properties
$xmlData.PrivacyPolicies.Property | ForEach-Object{
$property = $pspm.GetPropertyByName($_.Name)
if($property -ne $null)
{
$Privacy=$_.Privacy
$PrivacyPolicy=$_.PrivacyPolicy
$property.DefaultPrivacy = [Microsoft.Office.Server.UserProfiles.Privacy]::$Privacy
$property.PrivacyPolicy =[Microsoft.Office.Server.UserProfiles.PrivacyPolicy]::$PrivacyPolicy
$property.Commit()
write-host -f green $_.Name property privacy policies are modified successfully
}
else
{
write-host -f yellow $_.Name property does not exists
}
}
}
#----------------Calling the function---------------------------------------------
SetPrivacyPolicies Run the Script:
Go to Start.
Click on All Programs.
Click on Microsoft SharePoint 2010 Products and then click on SharePoint 2010 Management Shell.
Run the C:\Users\Desktop\ContentSources\SetPrivacyPolicies.ps1
Output:
And in the Central Administration you could see the Privacy Policy Settings modified for User Profile properties.
Comentários