How to modify an item's value in a SharePoint list with PowerShell

后端 未结 2 1207
暖寄归人
暖寄归人 2021-01-20 11:08

How do I use PowerShell to modify an item\'s value in a SharePoint list? When I try the following:

$splist.GetItems() | ForEach-Object{
 #Write-Host $_[\"Ite         


        
2条回答
  •  灰色年华
    2021-01-20 11:17

    Using powershell I did it very perfectly with the script from social.msdn.microsoft.com/Forums

    Here is sample code, Tyepe "YES" to proceed once prompted. and Replace the only two variable: (urlToTheYourSite & YourListNameToDelete)

    write-host "This will delete data, type YES to continue"
    $retval = read-host 
    if ($retval -ne "YES") 
    {
        write-host "exiting - you did not type yes" -foregroundcolor green
        exit
    }
    write-host "continuing"
    
    $web = get-spweb https://urlToTheYourSite
    $list = $web.lists | where {$_.title -eq "YourListNameToDelete"}
    Write-host "List $($list.title) has $($list.items.count) entries"
    $items = $list.items
    
    foreach ($item in $items)
    
    {
        Write-host "  Say Goodbye to $($item.id)" -foregroundcolor red
    
        $list.getitembyid($Item.id).Delete()
    }
    

提交回复
热议问题