Quantcast
Channel: it's possible to give a line break in Newsfeed Post? (via powershell) - SharePoint Stack Exchange
Viewing all articles
Browse latest Browse all 3

it's possible to give a line break in Newsfeed Post? (via powershell)

$
0
0

New post provisioned via powershell script to a Newsfeed:

$site = Get-SPSite "siteurl"
$ServiceContext = Get-SPServiceContext $site
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$Profiles = $ProfileManager.GetEnumerator()    
$profile = $ProfileManager.GetUserProfile($ContextUserLogin)
$feedManager = new-object Microsoft.Office.Server.Social.SPSocialFeedManager($profile, $serviceContext);
$linkItem = new-object Microsoft.Office.Server.Social.SPSocialDataItem
$linkItem.ItemType = [Microsoft.Office.Server.Social.SPSocialDataItemType]::Link;
$linkItem.Text = $NewsfeedSettings;
$linkItem.Uri = New-Object System.Uri($site.Url + "/_layouts/15/EditProfile.aspx");
$userItem = new-object Microsoft.Office.Server.Social.SPSocialDataItem
$userItem.ItemType = [Microsoft.Office.Server.Social.SPSocialDataItemType]::User
$userItem.AccountName = $MentionedUser

$newsFeedData = new-object Microsoft.Office.Server.Social.SPSocialPostCreationData
$newsFeedData.ContentText = ("user {1} and link {2}")
$newsFeedData.ContentItems = $userItem, $linkItem
$newPost = $feedManager.CreatePost($null, $newsFeedData)

Via UI is possible to give a line break (SHIFT+ENTER), however via the above call it's not. Some tested encodings displayed as text: \n </br> &#10;

Notes:

  • "Gets or sets the plain text of the post, which may include positional insertion tokens (for example, "Today is {0}'s birthday!")." from MSDN SPSocialPostCreationData
  • Post entries objects have a different content type when created via UI or SPSocialFeedManager.CreatePost

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images