Wrong Discussion Board item name when i create a new Discussion item using power-shell RRS feed

  • Question

  • i have the following case:-

    1. a team site collection inside sharepoint 2013 on-premise.

    2. i have enabled the publishing infrastructure site collection feature and site feature for the team site collection.

    3. i added a new Discussion Boardt list inside the team site

    4. now we have old announcements that were sent by emails and paper announcements, which we want to add inside the new sharepoint Discussion Board list.

    5. so i try the following power-shell script which will create a new Discussion Board item :-

    $web = Get-SPWeb "http://servername/"  
    $list = $web.Lists["News & Announcements"]  
    $newItem = $List.AddItem()   
    $newItem["Title"] = "Test announcment"  
    $newItem["Name"] = "Test announcment" 
    $newItem["Body"] = "test body"  
    $newItem["Modified"] = "9/3/2015"
    $newItem["Created"] = "8/3/2015"  
    $user = $web.EnsureUser("\staging.user")  
    $newItem["Editor"] = $user  
    $newItem["Author"] = $user  

    now the above power-shell script will populate the following item:-

    which looks fine, except for the item name which will be "ITEMID_.000", .. so can anyone advice on this? why i am getting wrong item name when i create the Discussion Board item suing power-shell? are there missing fields/parameters i need to pass?

    Note. when i check the item compliance details, it clearly showed where is the problem, as the item name will be "265_.000". so seems passing the item name

    $newItem["Name"] = "Test announcment" 

    is not working...


    • Edited by johnjohn11 Thursday, December 22, 2016 2:03 PM
    Thursday, December 22, 2016 11:59 AM


  • Hi John,

    It seems the same question has been answered in another forum, we can use the PowerShell script below to create new discussion item:

    $web = Get-SPWeb "http://sp/sites/team" 
    if($list -ne $null)
    $newTopic = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewDiscussion($list, "Test announcment"); 
    $newTopic["Body"] = "test body";
    $newTopic["Modified"] = "9/3/2015"
    $newTopic["Created"] = "8/3/2015"  
    $user = $web.EnsureUser("contoso\administrator")  
    $newTopic["Editor"] = $user  
    $newTopic["Author"] = $user  
    Write-Host $newTopic.Title " discussion topic is created successfully"
    Write-Host "List does not exists." 

    More information:


    Best Regards

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Friday, December 23, 2016 9:29 AM