I am trying to do the following but I have some exceptions, I dont know whats wrong with this.

Update 2:

    $site = Get-SPSite -Identity "http://url/workspaces/TS1/"
$list = $site.RootWeb.GetList("/workspaces/TS1/Lists/WorkspaceAccessRights")

I tried this simple 1. and it says

Exception calling "GetList" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
At line:15 char:30
+ $list = $site.RootWeb.GetList <<<< ("/workspaces/TS1/Lists/WorkspaceAccessRights/")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Rather than using

$spList = $spWeb.GetList("/Lists/Mylist")


$spList = $spWeb.Lists["My list"]


$spList = $spWeb.GetList("/sitename/Lists/Mylist")

It seems like all the errors are related to the fact that $spList is null.

  • pls see my update, last line is throwing Cannot convert value to type System.String. At line:31 char:18 + Write-Host "$spWe <<<< b" + CategoryInfo : NotSpecified: (:) [], RuntimeException + FullyQualifiedErrorId : RuntimeException – Luis Valencia Apr 11 '12 at 12:47
  • Is this a typo? $spList = $web.Lists["Workspace Access Rights"] where you have $web instead of $spWeb? – Robert Kaucher Apr 11 '12 at 13:04
  • psl see the edit, now access denied?, this is weird – Luis Valencia Apr 11 '12 at 13:28

I have solved with this blog: http://www.stilldesign.co.nz/Blog/post/2011/06/21/Painful-SharePoint-error-when-using-PowerShell.aspx#comment

Perhaps I should have mentioned that I am using POWERGUI, after checking the logs at the exact same time of the script execution, I could copy and paste the error and find the blog above.

I blogged about this here: http://levalencia.wordpress.com/2012/04/12/unable-to-cast-com-object-of-type-microsoft-sharepoint-library-sprequestinternalclass-to-interface-type-microsoft-sharepoint-library-isprequest/

  • 1
    Don't forget to select this as the answer. Also, it would be a good idea to give a short explanation of what was going on in case the post is deleted or the site goes away. – Robert Kaucher Apr 11 '12 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.