Get-SPWeb : Cannot find an SPWeb object with Id or Url

When executing the Get-SPWeb PowerShell cmdlet as a farm administrator, I received the following error:

get-spweb error

Quick and simple fix, Add-SPShellAdmin should have given me enough permissions for executing the command, but I forgot to specify the content database. This is crucial if you want to create PowerShell objects that are existing within these content databases.

Finding the contentdatabase of a web application can be done quickly with Get-SPContentDatabase.

Here’s a sample script that will create a contentdatabase object, which is used as a parameter for the Add-SPShellAdmin cmdlet.

$db = Get-SPContentDatabase -site http://sharepoint
Add-SPShellAdmin -UserName SP\SP_User -database $db

The error could’ve been a bit more descriptive than “Cannot find” in my opinion.

Advertisements

2 thoughts on “Get-SPWeb : Cannot find an SPWeb object with Id or Url

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s