The issue - I have a number of SP 2010 webs under a main address, as in

http://mysite/web name 1 
http://mysite/web name 2 

Doing a Get-SPWeb for the first two works fine

$SPWeb = Get-SPWeb http://mysite/webname1

but it fails when I try to do it for the second

$SPWeb = Get-SPWeb http://mysite/web%20name%201

I get the "Cannot find an SPWeb object with Id or Url" error

I knew enough to encode the address - you get a completely different set of errors if you try to do it with spaces.

The various sites have the same design, I'm pretty sure it's the space that's throwing off the call, but I can't find the syntax/process to make the call work for the spaced addresses.



4 Answers 4


It would be $SPWeb = Get-SPWeb "http://mysite/web name 2"


You need to put quotes around parameter

$SPWeb = Get-SPWeb "http://mysite/web name 1"

I see where the mis-step was. I tried passing the address as a variable, thinking that would make it work more correctly. But I then used it as one normally would:

$SPWeb = Get-SPWeb $SPWebName

which still returned the error.

To pass it as a variable, I needed to put the call to the variable in quotes, something I wasn't used to:

$SPWebName = "http://mysite/web name 1"
$SPWeb = Get-SPWeb "$SPWebName" 

I KNEW it was going to be something stupid.


Not use the $SPWebName as a string parameter, it will just a variable,

$SPWebName = "http://mysite/web name 1"
$SPWeb = Get-SPWeb $SPWebName

Then check if the site url is valid.

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.