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

I can successfully connect to the "Shared Documents" library at root site and add a file to it. What I can't do is connect to a library that is a few layers down so I can add the file:

The Root Site is: http://mycompany/sites

Connection code:

 $web =Get-SPWeb "http://mycompany/sites"
 $spFolder= $web.GetFolder("Shared Dcouments")
 $web =Get-SPWeb "http://mycompany/sites/Operations/IT"
 $spFolder= $web.GetFolder("Shared Documents")

I have tried:

 $web =Get-SPWeb - identity "/Operations/IT"  -site "http://mycompany/sites"
 $web =Get-SPWeb - identity "http://mycompany/sites/Operations/IT"

No matter how I do it, I can an error similar to: Get=SPWeb :

Cannot find an SPWeb onject with ID or URL : http://mycompany/sites/Operations/IT

I am very new to powershell, and fairly new to SharePoint- there may be a simple answer, but I can't find it.

share|improve this question
    
I found the correct syntax- not sure why it wasn't working earlier: $SubSiteUrl="mycompany/sites/operations/it"; $web =Get-SPWeb -Identity $SubSiteUrl –  Rick Apr 23 '12 at 13:14
1  
If you find the answer, please use the answer tool, not comment. Then mark your questions as answered. This will help future user with the same kind of issue to find the solution –  Steve B Sep 10 '12 at 9:05
    
Yes, please add an answer. It looks like from your example code you had a space between the - and Identity? –  Robert Kaucher Jun 23 '13 at 0:00
add comment

1 Answer

Q: Is is local? It is remote (another server) you need to enable Powershell Remote (see here http://blogs.msdn.com/b/opal/archive/2010/03/07/sharepoint-2010-with-windows-powershell-remoting-step-by-step.aspx)

Also make sure you got the right of course use this http://bramnuyts.be/2011/06/08/get-spweb-cannot-find-an-spweb-object-with-id-or-url/

The simple should be $spWeb = Get-SPWeb -Identity http://sp.local not even needed to put it in the quotes!

Afterwards use the $spWeb variable to do anything on it.

Make sure you can access it by browser of course.

Hope it helps, C:\Marius

share|improve this answer
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.