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

When writing my powershell code, the openweb command returns an empty object.

this is the code:

PS C:\Users\SP_admin> $spsite = get-spsite "https://adress.nl/sites/dcprogrammabureau"


PS C:\Users\SP_admin> $spsite

Url
---
https://adress.defriesland.nl/sites/dcprogrammabu...

PS C:\Users\SP_admin> $web = $spsite.openweb()
PS C:\Users\SP_admin> $web

Url
---

I am admin, i have rights but i do not get a web object! On my single server farm everything works just fine, on my multiple server farm however i get nothing!

The two web front ends are load balanced using an ISA server. When calling the site directly on the machine i get the same result.

Any ideas?

share|improve this question
    
Is this related to your other post: sharepoint.stackexchange.com/questions/17247/…;? In all likelihood, the root cause is the same. –  Rob D'Oria Aug 8 '11 at 14:23
add comment

4 Answers

nldev,

Actually the real reason for the empty object is that you do not have the correct permissions on the database. Go into SQL Server and add your account (same one you're using in PowerShell) to SQL Server Logins. Then give your account permissions on the SharePoint database that is associated with your Web Application (e.g. WSS_Content, but can be different).

You also might have to run PowerShell as farm admin and run the command Add-SPShellAdmin -UserName YourUserName, otherwise you might get errors preventing you from using certain SharePoint PowerShell commands.

share|improve this answer
add comment

I think the easiest way to fix your problem is use the Cmdlet Get-SPWeb.

http://msdn.microsoft.com/en-us/library/ms473942.aspx

Or why do you want to use Get-SPSite and and later Get-SPWeb?

share|improve this answer
    
Thansk for the help, the problem was a security issue. –  nldev Sep 13 '11 at 8:05
add comment
up vote 0 down vote accepted

For future reference, the issue was security and rights. When i logged in using the sp_farm account, everything worked fine.

However i do not know what the difference between the SP_Admin and SP_Farm account are, i will ask if the rights in the DB are different, maybe the db_creator and security_admin roles where removed for SP_Admin

share|improve this answer
add comment

The only thing I can think of is that there is no root web site on the site collection. The site collection and the root web at the site collection are two different things. The documentation (http://msdn.microsoft.com/en-us/library/ms473155.aspx) for OpenWeb() says that it returns the lowest level web in the web string passed into the SPSite constructor. In your case, that would be the root web of the https://adress.nl/sites/dcprogrammabureau site collection. Not sure if that is the issue, but it might be.

share|improve this answer
    
Thanks for thinking with me but i foudn the solution, it was a security issue. I will write the answer down here. –  nldev Aug 9 '11 at 11:15
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.