1

我在“$spWeb.List”行中得到“无法索引到空数组”

我正在使用 Windows7 家庭高级版和 Sharepoint Foundation 2010

我尝试将用户添加到 shell Add-SPShellAdmin -username -database .. 失败通知错误是帐户名已作为登录名添加到数据库中,使用的用户名与帐户不同

请建议!

"============================================================================="
$PSSnapin = Remove-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null
 $PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue |    Out-Null

$spWeb = Get-SPWeb http://krishna-hp:11944/sites/sh100/
$spList = $spWeb.List["products"] 

$newItem = $splist.Items.Add()

$newItem["Title"] = "this is title"
$newItem["product_id"] = 34
$newItem["product_desc"] = "this is from poershell"
$newItem["price"] = 123
$newItem.Update()
4

1 回答 1

1

很简单只要换行

$spList = $spWeb.List["产品"]

$spList = $spWeb.Lists["products"] 成功了!

于 2012-05-25T11:40:19.430 回答