I'm working in a Sharepoint 2007 environment. I'm trying to loop through a site, and it's subsites, and add a webpart to any pages found.
#Add SharePoint assemblies
[system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
[system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint.publishing")
#Get site and web objects
$site = New-Object Microsoft.SharePoint.SPSite(http://test.fake.com/en-us/testsite/)
#Walk through each Publishing Web and add the content editor webpart
foreach ($web in $site.AllWebs) { #add webpart here }
My problem is that $site returns http://test.fake.com.. so when I hit my foreach loop it starts hitting anything under fake.com, and not /en-us/testsite/ and whatever sites below it. Is there something other than the SPSite object I should be using to accomplish what I want? Saying I'm new to this would be an understatement.. so bear with me.
Thanks for any help/insight.