2012-06-21 89 views
2

在SharePoint提交了項目,這是一些代碼,我寫道:嘗試修改使用PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell 

$webURL = "http://nycs00058260/sites/usitp" 
$lists = "OsEM1","OsEM2","OsEM3","OsEM4" 
$web = Get-SPWeb -Identity "http://nycs00058260/sites/usitp" 
foreach($list in $lists) 
    ... ... 
    Write-Host $item["Title"] 
    #$item["Item"]=$item["Title"] +" ,"+$webURL+"\"+$filename 
    $item["Item"]="$tmpValue"+" ,$item[Title]" 
    $item.Update() 
    } 
} 
} 

它說:無法索引類型MicroSoft.SharePoint.SPListItem的對象。 當我更改$ item [「Item」]的值時,會發生什麼事情?

回答

0

有導致此行爲的幾個原因:

  • 您的權限不匹配,則需要更改項目內容。如果您擁有PowerShell權限,通常情況並非如此。
  • 您的列表已被破壞。這可能與網站欄,內容類型,列表本身或視圖有關。如果你創建並沒有更新列表模式(定義),它不會讓你編輯它。
  • 對於SPWeb(站點)對象,您沒有將AllowUnsafeUpdates設置爲打開。

所有這三個問題通常都有更好的(匹配)錯誤消息,但有時SharePoint並不會爲您提供錯誤消息中需要的所有信息。

如果您需要更多詳細信息,請詢問。