Thursday, June 30, 2011

Creating SP 2010 Sites using PowerShell

We all know PowerShell is recommended command line tool for SharePoint 2010. But PowerShell does not support the same style as the UI supports.
I ran in to problem, when I was creating sites using PowerShell. After creating sites I was not able to see the default groups (Members, Visitors and Owners) for the site. But when you create site from UI, you have all those available.
I figured out that, we need to execute one more command in order to get that. The steps can be as listed below:
1. Create Site, either using New-SPSite or simple .NET style code to add site to web application $WebApp.Sites.Add(params....).
2. After that execute command as :
$CurrentWeb.CreateDefaultAssociatedGroups($PrimaryOwnerLogin,
$SecondaryOwnerLogin,
$CurrentWebTitle)

It will create the groups with the current site title for e.g. MyProjects Members.

Friday, June 24, 2011

SharePoint 2010 with search scope on managed path

I came across this while trying to restrict my search on a specific managed path. I tried a lot options and at last the tricky configuration did the work. The steps to do so can be as below:

1. Go to central admin site of your farm.
2. Navigate Application Management --> Manage Service Connections.
3. Locate Search Service Application. Select it by click it in the same row. (as usual step in SP 2010).
4. From left quick launch, navigate to scopes.
5. Create New Scope with your preferred title, description and specify your custom search result page (ex - salesresults.aspx)
6. Create rule as :
select Scope Rule Type as Web Address,
select Web address as http:/// (ex - http://myserver/sales)
select behavior as include.
7. Now go to your search center, where you have created your custom search tab.
8. Go to the result page (which is created using search results page layout) for that custom tab.
9. Edit page and locate search core results web part on bottom of page.
10. Edit the web part.
11. Expand location properties. In the Scopes text box, enter your scope name which is created in step 5 above.
12. save web part settings and save page. checkin the page and publish it.
13. when you search on this custom tab, on refiner list under site, you can only sites available under the managed path.

Done.