Updates
Note that you can use a wildcard entry as per this blog thx Todd
Microsoft now recommends using no host header
https://technet.microsoft.com/en-us/library/cc424952.aspx#section2a
CREATING HOST-NAMED SITE COLLECTIONS IN SHAREPOINT 2013
https://sergeluca.wordpress.com/2014/01/13/creating-host-named-site-collections-in-sharepoint-2013/
Quickly Migrate SharePoint Path-based to Host-named Site Collections Using Feb 2015 PU
NHSC Lab without Host Header
Note you will need to add the following for the above example powershell to work properly.
- Create managed account called … 'Contoso\JDoe'
- DNS CNAME Record for portal.contoso.com using ‘nyc-sp1’
Three lines of powershell from Technet
New-SPWebApplication -Name 'Contoso Sites' `
-port 80 -ApplicationPool ContosoAppPool `
-ApplicationPoolAccount `
(Get-SPManagedAccount 'Contoso\JDoe') `
-AuthenticationProvider ~
(New-SPAuthenticationProvider `
-UseWindowsIntegratedAuthentication)New-SPSite 'http://nyc-sp1' -Name 'Portal' `
-Description 'Portal on root' `
-OwnerAlias 'contoso\administrator' `
-language 1033 -Template 'STS#0'New-SPSite 'http://portal.contoso.com' `
-HostHeaderWebApplication 'http://nyc-sp1' `
-Name 'Portal' -Description 'Customer root' `
-OwnerAlias 'contoso\administrator' `
-language 1033 -Template 'STS#0'
I don’t like the database name from Technet code so think about creating database with a better name!
add -databasename ContosoSites
NHSC Lab using Host Header
So the future for Microsoft is to use Host Named Site Collections and since we have no GUI, my challenge has been to script this via PowerShell. But many examples on the web have come up short and since I have been real busy this project has been put on the back burner. Finally!
For my students, I am using 20331 Lab 8 but you can use any SharePoint farm, but you will need to modify the IP address and domain names as needed.
Using 20331 Lab 7/8 verified
Prerequisite #1 - Create DNS Records
A Record
webapp.contoso.com – 172.16.1.22
CNAME Records
root.contoso.com - webapp.contoso.com
companyA.contoso.com - webapp.contoso.com
companyB.contoso.com - webapp.contoso.com
Prerequisite #2 – Add 172.16.1.22 to NIC
Prerequisite #3 – Edit BackConnectionHostNames
Using regedit navigation to
add values for the all four sites added to DNS earlier.
Prerequisite #4 – Here is the script
1: # Using 20331 lab 8 vm
2: # DNS and TCPIP prerequisites
3: # create A record for webapp.contoso.com `
to 172.16.1.22 and add 172.16.1.22 to NIC
4: # create cname records to webapp.contoso.com`
for webapp, root, companya, companyb
5: # add sites to backconnectionhostnames if`
needed
6:
7: # Load SharePoint PowerShell Snapin
8: Add-PSSnapin microsoft.sharepoint.powershell
9:
10: # Web Application Variables
11: $webapphostheadersimple = 'webapp.contoso.com'
12: $webapphostheader = 'http://webapp.contoso.com'
13: $webappname = 'Portal WebApp'
14: $language = '1033'
15: $ipaddress = '172.16.1.22'
16:
17: # Site Collection Variables
18: $RootSC = 'http://root.contoso.com'
19: $rootSCname = 'Root Site'
20: $HNSC1 = 'http://companyA.contoso.com'
21: $HNSC1name = 'Company A'
22: $HNSC2 = 'http://companyB.contoso.com'
23: $HNSC2name = 'Company B'
24:
25: $rootsitetemplate = 'STS#0'
26: $sitetemplate = 'BLANKINTERNET#0'
27: $webdb = 'wss_content_portal'
28:
29: # Account Variables
30: $owneralias = 'contoso\administrator'
31: $serviceaccount = 'contoso\spcontosocomapppool'
32:
33: # Create Authentication Provider
34: $ap = new-spauthenticationprovider -usewindowsintegratedauthentication
35:
36: # Create New Web Application
37: new-spwebapplication -name $webappname `
-hostheader $webapphostheadersimple -port 80 `
-applicationpool $webappname -applicationpoolaccount`
$serviceaccount -databasename $webdb `
-allowanonymousaccess -authenticationprovider $ap
38:
39: # Create IIS Binding
40: new-webbinding -name $webappname `
-hostheader "*" -ipaddress $ipaddress `
-port 80 -protocol http
41:
42: # Create root site collection
43: new-spsite $RootSC -hostheaderwebapplication`
$webapphostheader -name $rootSCname –description `
$rootSCname -owneralias $owneralias -language`
$language -template $rootsitetemplate
44:
45: # Create host named site collection for CompanyA
46: new-spsite $HNSC1 -hostheaderwebapplication`
$webapphostheader -name $HNSC1name -description`
$HNSC1name -owneralias $owneralias -language`
$language -template $sitetemplate
47:
48: # Create host named site collection for`
CompanyB
49: new-spsite $HNSC2 -hostheaderwebapplication`
$webapphostheader -name $HNSC2name -description`
$HNSC2name -owneralias $owneralias -language`
$language -template $sitetemplate
Results – Here are site collections and web application
Option Step - If needed edit IIS bindings
Appears to work fine with unassigned binding for webapp.contoso.com
No comments:
Post a Comment