Task
I needed to modify "Activities I want to share in my newsfeed" value centrally for all users in a SharePoint 2013 farm.
Solution
With the following PowerShell, you can set all options checked.
$Site = Get-SPSite -Limit 1
$ServiceContext = Get-SPServiceContext($Site)
$ProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$Profiles = $ProfileManager.GetEnumerator()
foreach ($Profile in $Profiles)
{
# 4095 is decimal value of 111111111111, meaning all options are checked.
# Binary value describes what options are checked
# so 000000000001 --> 1 (1 being the value you want to set as the field value
# would mean only "Participation in communities" would be checked
$Profile["SPS-PrivacyActivity"].Value = 4095
$Profile.Commit()
}
Technorati Tags: SharePoint 2013
Hi,
ReplyDeletethank you for that post...
I tried to use the script but got the following error. Can you help?
New-Object : Ausnahme beim Aufrufen von ".ctor" mit 1 Argument(en):
"UserProfileApplicationNotAvailableException_Logging ::
UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does
not have 67432d2a-6d29-4cb4-a7a0-e617b565d5f3"
In C:\temp\NeewsfeedSettings.ps1:4 Zeichen:19
+ $ProfileManager = New-Object
Microsoft.Office.Server.UserProfiles.UserProfileMan ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Hi Dominic,
ReplyDeleteMake sure the account you run the PowerShell script with has Full Control permission on the User Profile Service Application. Alternatively log in and run the script with account that has such permissions.
Hi again,
ReplyDeleteI ran the Shell as farm admin and it works. great!
Thanks.....
Hi, how can i target users in a specific AD group with this script?
ReplyDeleteCheers
Shane
SharePoint User Profile Service doesn't know anything about AD groups so you need to fetch AD group user account names first, then do a for each loop to modify each user profile one by one.
DeleteGreat post. Works for me.
ReplyDeleteThe binary number sequence is other way around. e.g. If you want to mark only Participation in communities, you will have to provide value 2048 (100000000000). Tested in SP2013.
Thank you Xeeshan for the update. Much appreciated!
DeleteDo you know of a way I can do this in SharePoint Online?
ReplyDeleteHave you tried this which lists properties including this, and modify it to update the value? https://gallery.technet.microsoft.com/office/Retrieve-all-SharePoint-357e2936#content
ReplyDeleteomg thank you so much! there is absolutely no documentation about this, and every blog about the old outdated 2010 Feed wich is done entirely different.
ReplyDeletethis helps me really a lot, even years later, hahah.