Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
share|improve this question
add comment

2 Answers 2

Rather than using

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

try

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

or

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

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

share|improve this answer
    
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 –  L.V. Sharepoint Architect 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 –  L.V. Sharepoint Architect Apr 11 '12 at 13:28
add comment
up vote 1 down vote accepted

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/

share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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