Add Reply to Discussions List by Powershell

10/02/2016 09:16

Add-PSSnapin microsoft.sharepoint.powershell -ea 0
$webUrl = "https://yourCommunitysiteUrl"
$viewUrl = "/Lists/Community%20Discussion"
$parentId = 1;

$web = Get-SPWeb $webUrl

$listUrl = $web.ServerRelativeUrl + $viewUrl
$list = $web.GetList($listUrl);
$list.Title

$parent = $list.GetItemById($parentId);

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint")

$item = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewDiscussionReply($parent)
$item["Body"] = "My PS body";
$item.Update();