TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Create a discussion topic in SharePoint 2010 using Powershell
Vijai Anand Ramalingam
Oct 17, 2018
9.5
k
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog you will see how to create a new discussion topic in SharePoint 2010 using Powershell
I have a Discussion list in which i need to add a new topic in SharePoint 2010 using Powershell.
Powershell Script:
$site=Get-SPSite
"http://serverName/sites/VJTesting/"
$web=$site.OpenWeb()
$list=$web.Lists.TryGetList(
"Team Discussion"
)
if
($list -ne $null)
{
$newTopic = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewDiscussion($list,
"Topic6"
);
# In the "body" column you can add the HTML content so that you can add images and add the styles for the contents.
# To get the HTML content - Go to the "Discussion" list, then click on "Add new Discussion".
# In the body column add the contents and images.
# In the ribbon interface, click on "Editing Tools" and then click on "Format text" tab.
# In the "Markup" group you could see "HTML" option.
# Click on the down arrow and then click on "Edit HTML Source".
# Copy the HTML source.
$newTopic[
"Body"
] =
"<div class='ExternalClassF7F26CE68055477797898F1D2250E309'><div class='ExternalClass37FC140BAA764AAD9DAB0F050FD45712' style='color: #ec008c; text-decoration: underline'><p><strong>"
My
new
Topic.
"<img alt='DISCUSS.GIF' src='/sites/VJTesting/SiteAssets/Lists/Team%20Discussion/EditForm/DISCUSS.GIF' style='margin: 5px'/><br/><br/></strong>?</p></div></div>"
;
$newTopic.Update();
Write-Host -ForegroundColor Green $newTopic.Title
" discussion topic is created successfully"
}
else
{
Write-Host -ForegroundColor Yellow
"List does not exists."
}
Create a discussion topic in SharePoint 2010 using Powershell
Next Recommended Reading
Create Asset Library in SharePoint 2010 using Powershell