1

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?

1

4 Answers 4

1

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.

1
  • Thanks for thinking with me but i foudn the solution, it was a security issue. I will write the answer down here.
    – nldev
    Commented Aug 9, 2011 at 11:15
1

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.

0

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

0

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?

1
  • Thansk for the help, the problem was a security issue.
    – nldev
    Commented Sep 13, 2011 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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