Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Create a discussion topic in SharePoint 2010 using Powershell
WhatsApp
Vijai Anand Ramalingam
6y
9.6
k
0
2
25
Blog
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
Up Next
Create Asset Library in SharePoint 2010 using Powershell
Ebook Download
View all
SharePoint Framework (SPFx) A Developers Guide
Read by 11.1k people
Download Now!
Learn
View all
Membership not found