我对powershell和sharepoint非常陌生,我很难尝试创建一个函数。
我正在尝试创建一个泛型函数来将新项添加到SPList中,但我无法将SPList传递给该函数。
这是我的功能原型:
function Add-IntoList([Microsoft.SharePoint.SPList] $List,[hashtable] $Columns)
{
... some code
}下面是我对这个函数的调用:
$web = Get-Web("http://some_url/sandbox1") #It returns the Get-SPWeb
$test = @{"Title" = "Olympia"; "Body" = "Salem"}
Add-IntoList($web.Lists["Announcements"], $test)不管用,我不明白为什么。下面是powershell告诉我的错误:
Add-IntoList : Cannot process argument transformation on parameter 'List'. Cannnot convert the "System.Object[]" value of type "System.Object[]" to type "Microsoft.Sharepoint.SPList".我做错什么了?
提前谢谢你,尼古拉斯
发布于 2014-05-13 18:06:46
当您调用该函数时,而不是像这样调用它:
Add-IntoList($web.Lists["Announcements"], $test)就像:
Add-IntoList $web.Lists["Announcements"] $testhttps://stackoverflow.com/questions/22255562
复制相似问题