SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

this is the code:

PS C:\Users\SP_admin> $spsite = get-spsite ""

PS C:\Users\SP_admin> $spsite


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


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:…;? In all likelihood, the root cause is the same. – Rob D'Oria Aug 8 '11 at 14:23

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 ( 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 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


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
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

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

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

Your Answer


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.