lundi 16 mars 2015

$SPWeb.GetList - Exception



I am trying to get a list using PowerShell, so I am executing this code:



$list = $web.GetList($web.Url +"lists/TestList")


It's giving me:



Exception calling "GetList" with "1" argument(s): "0x80070002" At line:1 char:1 + $list= $web.GetList($web.Url +"lists/TestList") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : FileNotFoundException



How do I get a list by its Title, if I run this:



$list = $web.Lists | ? {$_.Title -eq "TestList"}


Wouldn't this loop through all lists in the site which will be bad for performance? Thanks for any hint to guide me to the right direction.








0 commentaires:

Enregistrer un commentaire