Create HNSC with Powershell and set some settings

posted in: HNSC, PowerShell 0

This script creates a host named site collection in a web app that is named SharePoint – HNSC.  You can modify it to your hearts content.


If you replace Domain with the name of your domain, e.g. say you login with springfield\JoeUser, then you could replace domain with springfield.

The servername can either be a single server or it could be a comma separated list of servers.

The primary site collection admin, secondary site collection admin, their email aliases, and the 3rd site collection admin should be replaced as well, along with the second reference to the servers.

After you make those modifications you can run this from an administrative powershell.

To create a shortcut on your desktop of the server that calls this script, save it in C:\scripts, name it new-hnscsitecollection.ps1 and then make a shortcut that points to the following

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -file “C:\Scripts\New-HNSCSiteCollection.ps1”

Make sure that you right click the new shortcut, click properties, advanced, and then select ‘Run as Administrator’

When you run it

It will prompt you for the name for your site and the URL.  When it comes to these names try and keep the URL short, don’t worry about spaces, the script will remove them.  And you can have a different site name than the URL.

This script disables:

Minimal Download Strategy

Limited-Access user permission mode

and it De-activates the Open in Client Feature

The script enables:


SharePoint Standard and Enterprise Features

Office Web apps (this assumes you have office web apps or office online server as it’s known now bound to your farm)

Finally it creates a binding in IIS for all of your servers.

Happy SharePointing and Cheers, Stacy