Ref: Msdn
I just had to put this up here as I was asked this in one of my interview questions a while back. Pretty cool stuff.
Create a host-named site collection
You must use Windows PowerShell to create a host-named site collection. You cannot use the SharePoint Server 2010 Central Administration Web application to create a host-named site collection, but you can use Central Administration to manage the site collection after you have created it.
You can create a host-named site collection by using the Windows PowerShell New-SPSite cmdlet with the -HostHeaderWebApplication parameter, as shown in the following example:
1.To create a host-named site collection using Windows PowerShell, verify that you meet the following minimum requirements: See Add-SPShellAdmin.
2.On the Start menu, click All Programs.
3.Click Microsoft SharePoint 2010 Products.
4.Click SharePoint 2010 Management Shell.
5.From the Windows PowerShell command prompt (that is, PS C:\>), type the following:
CopyNew-SPSite http://host.header.site.url -OwnerAlias DOMAIN\username -
HostHeaderWebApplication http://servername
This creates a host-named site collection with the URL http://host.header.site.url in the SharePoint Server 2010 Web application with the URL http://servername.
Programmatically create a host-named site collection
In addition to using the Windows PowerShell to create host-named sites, you can use the SharePoint Server 2010 object model. The following code sample creates the host-named site collection with the URL http://host.header.site.url in the SharePoint Server 2010 Web application with the URL http://servername:
CopySPWebApplication webApp = SPWebApplication.Lookup(new
Uri("http://www.contoso.com"));
SPSiteCollection sites = webApp.Sites;
SPSite Site = null;
Site = sites.Add("http://hoster.contoso.com", "Site_Title",
"Site_Description", 1033, "STS#0", "contoso\owner",
"Owner_Display_Name", "Owner_Email", "contoso\secondaryowner,
"Secondary_Owner_Display_Name", "Secondary_Owner_Email", true);
SharePoint Server 2010 ships with a set of Web services for various user and administrative tasks. One of these administrative tasks is creating a new site collection. The CreateSite Web service method does not support the creation of host-named site collections. A workaround for this issue is to write a Web service that wraps the API sample code.
No comments:
Post a Comment