From the server itself this works:
Add-PSSnapin "Microsoft.SharePoint.PowerShell" $SPWeb = Get-SPWeb http://mysharepoint.org $SPList = $SPWeb.Lists["My List"] $SPListItem = $SPList.GetItemByUniqueId("<my unique id>") $SPListItem["Name"] = "stuff" $SPListItem["Title"] = "stuff" $SPListItem.Update() But remotely doing this:
$s = New-PSSession -ComputerName mysharepoint.org Invoke-Command -Session $s { Add-PSSnapin "Microsoft.SharePoint.PowerShell" $SPWeb = Get-SPWeb http://mysharepoint.org $SPList = $SPWeb.Lists["My List"] $SPListItem = $SPList.GetItemByUniqueId("<my unique id>") $SPListItem["Name"] = "stuff" $SPListItem["Title"] = "stuff" $SPListItem.Update() } Gets me:
You cannot call a method on a null-valued expression. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull + PSComputerName : mysharepoint.org
Cannot index into a null array. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray + PSComputerName : mysharepoint.org
Cannot index into a null array. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray + PSComputerName : mysharepoint.org
You cannot call a method on a null-valued expression. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull + PSComputerName : mysharepoint.org
Now clearly this is because I am getting a null list returned. But I can't understand why. Powershell Remoting is something I am just getting in to. How can I remotely update a list via powershell?
$SPWeb.Lists.TryGetList('List Name')?