I'm pretty new to powershell & sharepoint and i'm having hard time trying to create a function.
I'm trying to make a generic function to add new items into a SPList but i can't pass the SPList to the function.
Here is my function prototype:
function Add-IntoList([Microsoft.SharePoint.SPList] $List,[hashtable] $Columns)
{
... some code
}
And here is my call to the function:
$web = Get-Web("http://some_url/sandbox1") #It returns the Get-SPWeb
$test = @{"Title" = "Olympia"; "Body" = "Salem"}
Add-IntoList($web.Lists["Announcements"], $test)
And it doesn't work, i can't see why. Here is the error powershell tells me:
Add-IntoList : Cannot process argument transformation on parameter 'List'. Cannnot convert the "System.Object[]" value of type "System.Object[]" to type "Microsoft.Sharepoint.SPList".
What am i doing wrong ?
Thanks in advance, Nicolas