Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用SharePoint 2013中的powershell将列表项复制到另一个子网站列表_Powershell_Sharepoint - Fatal编程技术网

使用SharePoint 2013中的powershell将列表项复制到另一个子网站列表

使用SharePoint 2013中的powershell将列表项复制到另一个子网站列表,powershell,sharepoint,Powershell,Sharepoint,我尝试使用PowerShell将列表从根目录复制到子网站,如下面的代码所示,但在执行时出现错误,如下图所示。我的代码缺少什么 Add-PSSnapin "Microsoft.SharePoint.PowerShell" Set-ExecutionPolicy -ExecutionPolicy "Unrestricted" -Force $site= new-object Microsoft.SharePoint.SPSite("http://Sharepointroot") $web = $si

我尝试使用PowerShell将列表从根目录复制到子网站,如下面的代码所示,但在执行时出现错误,如下图所示。我的代码缺少什么

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Set-ExecutionPolicy -ExecutionPolicy "Unrestricted" -Force
$site= new-object Microsoft.SharePoint.SPSite("http://Sharepointroot")
$web = $site.Openweb()
$listroot = $web.Lists["Meeting Room Book"]
$itemsroot = $listroot.items
$siteapps = Get-SPWeb -Identity "http://sharepointroot/Apps"
$listapps = $siteapps.Lists["Meeting Room History"]
$i = 0
foreach ($item in $itemsroot) {
   $i++
   write-host -foregroundcolor yellow $i
   $newitem= $listapps.Items.Add()
   $newitem["Title"] = $item["Title"]
   $newitem["Booking_x0020_Date"] = $item["Booking_x0020_Date"]
   $newitem["End_x0020_Time"] = $item["End_x0020_Time"]
   $newitem["Booked_x0020_By"] = $item["Booked_x0020_By"]
   $newitem["Display"] = $item["Display"]
   $newitem["Category"] = $item["Category"]
   $newitem["Status"] = $item["Status"]
   $newitem["Recurrence"] = $item["Recurrence"]
   $newitem["Meeting_x0020_Title"] = $item["Meeting_x0020_Title"]
   $newitem["BB"] = $item["BB"]
   $newitem.update()
}
$web.dispose
$site.dispose
start-sleep 10
我有如下错误

You cannot call a method on a null-valued expression.
at line:5 char:1
+ $newitem= $listapps.Items.Add()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo          : InvalidOperation: (:) [],RuntimeException
+FullyUalifiedErrorID  : NullArray
编辑:
对于因me中的错误而关闭的此案例,所生成列表的名称不相同。谢谢你回答我的问题


对于代码复制列表到另一个子网站的工作

据我所知,此错误意味着脚本正在尝试执行某些操作,但脚本的另一部分没有任何信息来允许脚本的第一部分正常工作。在本例中,$TargetItem。

您在哪里声明了$TargetItem?对不起,我写错了,可能是$newitem no$TargetItem。我将编辑错误。。