Author Archives: admin

Advanced Promoted Links

SharePoint 2013 includes a special type of link app called “Promoted Links”, where Metro style icon tiles can be added to a web page, each with a background image. Microsoft use Promoted Links for the “Getting Started” panel commonly seen on the welcome page of a newly created site. Although Promoted Links add a modern and stylish look to a web page, they are not that versatile. This blog post explains how you can install and configure a free alternative to Promoted Links where you can adjust the size, colour and position of individual icon tiles.

  1. First visit the spjs blog site to download the necessary files to get started: http://spjsblog.com/2013/11/13/sharepoint-2013-style-tiles/
  2. Download two files shown:


3. Next download JQuery files shown:
   
Download the compressed, production jQuery 1.11.3 or
Download the compressed, production jQuery 2.1.4 (will not work with IE6, 7, or 8)

4. Add a “Script Editor” Web Part to the SharePoint page. Use the “INSERT SNIPPET” option to add the following code:

<div id=”spjs_tiles_placeholder” style=”margin:10px;float:left;clear:both;”></div>

<link href=”https://portal.contoso.com/sites/HR/SiteAssets/font-awesome-4.4.0/css/font-awesome.css” rel=”stylesheet”>

<link type=”text/css” href=”/sites/HR/SiteAssets/SPJS-Tiles.css” rel=”stylesheet”>

<script type=”text/javascript” src=”/sites/HR/SiteAssets/jquery-2.1.4.min.js”></script>

<script type=”text/javascript” src=”/sites/HR/SiteAssets/SPJS-Tiles_min.js”></script>

<script type=”text/javascript”>

spjs.tiles.init(“spjs_tiles_placeholder”,”MyTiles“);

</script>

You must change the css file href and the script src to point to your local files (SiteAssets).

When you save this code, and reload the page, you should see this banner:


5.  Click to create the SPJS-Tiles configuration list. It will be placed in the same site as you triggered this script. You should be redirected to the list after it has been created. If this fails, you can find the list in “All site content” as “SPJSTiles”.

6.  SPJS Tiles v1.2.2 and above includes support for “FontAwesome”. The above script (step 4) includes reference to local copies of the downloaded FontAwesome files. To download the files go to: http://fontawesome.io/icons/ More details are also provided on the spjs blog site – see http://spjsblog.com/2013/11/19/sharepoint-2013-style-tiles-change-the-size-and-color-of-the-tiles/

The downloaded files need to be added to the site’s “Site Assets” library also:


7.  Ensure the script (step 4) correctly references the URL location of the font-awesome.css added to the “Site Assets” library.

8. My sample SPJS-Tiles configuration list looks like:


Ensure that the Title contains the value added to the script (Text 4 highlighted) e.g. “MyTiles”. The Text appears inside the promoted link tile and includes MUI support, e.g. {“1033″:”English value”,”default”:”default value”}. You can add all the languages you have installed language packs for. Use “default” as a fallback if the language the user has selected has not yet been configured for the tile.

The Description appears when the mouse hovers over a promoted link tile. The Image column references a URL of an image if you optionally wish to display a background image in the promoted link tile. The FontAwesomeIcon column can optionally contain one of the available fonts from the http://fontawesome.io. web site. For example, for a Word Document image, the “file-word-o” class becomes “fa-file-word-o” text in this column. The FontAwesomeStyle determines how the icon appears. It follows the standard format of the HTML in-line Style tag. E.g. color:#ffffff;font-size:70px;padding-left:38px;padding-top:15px;

The BgColor can contain colour names to change the background colour of the promoted link tile. The TileSize determines how large the tile appears on the page. The URL defines where the promoted link tile links to.

The RefreshParent column is set to “Yes” for icon tiles. The Index column determines the order the tiles appear. On my example, the “00-00” defines a heading, “00-01” through to “00-03” defines three tiles on the first row, and “01-01” defines a tile on a second row.


9.  You can create custom promoted links based on how you configure the SPJS-Tiles configuration list. Here’s a couple of examples:

Without headings and with variable tile sizes:


 

With headings and with variable tile sizes:


Here is the SPJS-Tiles configuration list example for the above:



Adding Custom Refiners to SharePoint Search

Background
On this example, I have created multiple document type columns
– each document type column is uniquely paired to a content type. So for example, a “Meeting Document” content type includes a “Meeting Document Type” column, and a “Correspondence” content type includes a “Correspondence Document Type” etc.

RefinableString managed properties
To add a custom
refiner you must first map one or multiple crawled properties to one of the built-in Refiner managed properties. For this example, in Central Admin > Search Administration > Search Schema, I chose to use the “RefinanbleString01” managed property and map it to all the different document type crawled properties. You must select the crawled property starting with “ows_” for this to work. For example, the crawled property for Meeting Document Type is called “ows_MeetingDocumentType”. Once all mapped crawled properties are added, give the “RefinanbleString01” an Alias name so you can recognise it when configuring the Refinement Web Part.

Next run a full crawl.

When the crawl has completed, access the Search Results page where you wish to re-configure the Refinement Panel. Edit the Refinement Panel Web Part and click on the “Choose Refiners” button:

Add the e.g. “RefinableString01” managed property. In the properties displayed below give the refiner a Display Name – in my case “Document Type”. Click “OK” to save the Web Part’s settings and save/publish the search results page. Now try some searches and confirm the Refiner behaves correctly.

Testing how new document versions are handled when sent to a SharePoint 2013 Records Center

Introduction
There are a number of EDRM configuration options in SharePoint 2013 including ‘In-Place’ Records Management (IP-RM) and submitting documents to Records Centers (copying, moving, or moving and leaving a link). Detailed below is how a Records Center can be used to capture each document version as a record, whilst allowing the original document to continue to be updated.

Test 1: Submitting a copy of each major version of a document to a Records Center records library
1)  Upload ‘Caboodle TC’ document to a document library configured with a ‘Project Document’ content type and Major Versioning.

2)  Send a copy of ‘Caboodle TC’ to the Records Center.

3)  Check the Records Center Content Organizer rule correctly added the item to the ‘ProjectDocs’ records library.

4)  Update the original ‘Caboodle TC’ document to create a Version 2.0. Re-send a copy to the Records Center and check the Records Center ‘ProjectDocs’ records library.

The result is SharePoint adds the new major version to the same ‘ProjectDocs’ records library, but appends a unique code to the name of the copied item. The Records Center therefore stores a record per submitted version.

Test 2: Submitting a copy of each major version of a document to a Records Center records library
1)  Upload ‘ExcelDocument’ document to a document library configured with a ‘Project Document’ content type and Major Versioning.

2)  Send a copy of ‘ExcelDocument’ to the Records Center.

3)  Check the Records Center Content Organizer rule correctly added the item to the ‘ProjectDocsLibrary’ document library.

4)  Update the original ‘ExcelDocument’ document to create a Version 2.0. Re-send a copy to the Records Center and check the Records Center ‘ProjectDocsLibrary’ document library.

The same behaviour is exhibited, i.e. SharePoint creates a new item with an appended unique code in the ‘ProjectDocsLibrary’ within the Records Center. The Records Center therefore stores a record per submitted version.

So in conclusion, it is not possible to ‘overlay’ a superseded document version in the Records Center – separate items are always created. The only way around this would be using code/custom workflows. If In-Place RM was used to declare a published and approved item as a record, there would have to be a custom workflow process that un-declares the record to allow edited updates. The workflow would then manage the re-declaration of the In-Place record after it is re-published.

If records need to be declared, the workflow and custom development approach has to be recommended. I am personally in favour of using the Major & Minor Versioning and Content Approval capabilities of a standard document library without RM. You can still apply retention schedules and audit track events. The security trimming ensures that only relevant users can update the document and view draft copies. Only published/approved documents can be visible to the majority users by browsing or through search. Using the Search Results Web Part we can ensure that users always see the latest published version, whilst document owners can continue to work on draft versions.

If RM is not used in SharePoint you lose the ability to place holds on records and you lose the extra assurance that a document cannot be edited. However, the holds could be achieved programmatically with documents. The assurances can be derived from good security and auditing. I would therefore suggest that Records Centers are only used for the longer-term archiving of important or vital records, such as information on asbestos that needs to be kept for 50 years, or financial documents that need to be kept for 6 years etc. In-place records should only be used when documents no longer need to be updated, but the original context of the storage location needs to be retained.

How to create a Three Lines Search Display Template

Before starting ensure the SharePoint Server Publishing Infrastructure site collection feature is activated:

1.  Access SharePoint Designer 2013. Open the site to add a new search display template.

2.  Click on “All Files” and “_catalogs” and “masterpage” and “Display Templates” and “Content Web Parts”:

SharePoint Designer 2013 Display Templates

3.  Select the display template to base the new display template on. In this example I have created a new display template based on the “Item_TwoLines.html” file. Right-click and select “Copy”. Right-click and select “Paste”. (Note: The JavaScript pair file is created automatically).

4.  Select the copied item and rename it e.g. “Item_ThreeLines.html”. Wait for the JavaScript to correctly copy (use the Refresh function). Ensuring the new renamed html item is selected, right-click and select “Check Out”.

5.  With the item selected right-click and select “Edit File in Advanced Mode”. The Advanced Editor displays the HTML.

The updated “Item_ThreeLines.html” appears as below. The highlighted elements indicate what has been added to the Item_TwoLines.html code:

<html xmlns:mso=”urn:schemas-microsoft-com:office:office” xmlns:msdt=”uuid:C2F41010-65B3-11d1-A29F-00AA00C14882″>
<head>
<title>Three lines</title>
<!–[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt=”string”>0</mso:TemplateHidden>
<mso:ManagedPropertyMapping msdt:dt=”string”>&#39;Link URL&#39;{Link URL}:&#39;Path&#39;,&#39;Line 1&#39;{Line 1}:&#39;Title&#39;,&#39;Line 2&#39;{Line 2}:&#39;Title&#39;,&#39;Line 3&#39;{Line 3}:&#39;&#39;,&#39;FileExtension&#39;,&#39;SecondaryFileExtension&#39;</mso:ManagedPropertyMapping>
<mso:MasterPageDescription msdt:dt=”string”>This Item Display Template will show a small thumbnail icon next to a hyperlink of the item title, with an additional line that is available for a custom managed property.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt=”string”>0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
<mso:TargetControlType msdt:dt=”string”>;#Content Web Parts;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt=”string”>1</mso:HtmlDesignAssociated>
<mso:HtmlDesignStatusAndPreview msdt:dt=”string”>http://hsweb01/sites/navigate/_catalogs/masterpage/Display Templates/Content Web Parts/Item_ThreeLines.html, Conversion successful.</mso:HtmlDesignStatusAndPreview>
<mso:HtmlDesignConversionSucceeded msdt:dt=”string”>True</mso:HtmlDesignConversionSucceeded>
</mso:CustomDocumentProperties>
</xml><![endif]–>
</head>
<body>
<!–
Warning: Do not try to add HTML to this section. Only the contents of the first <div>
inside the <body> tag will be used while executing Display Template code. Any HTML that
you add to this section will NOT become part of your Display Template.
–>
<script> $includeLanguageScript(this.url, “~sitecollection/_catalogs/masterpage/Display Templates/Language Files/{Locale}/CustomStrings.js”);
</script>
<!–
Use the div below to author your Display Template. Here are some things to keep in mind:
* Surround any JavaScript logic as shown below using a “pound underscore” (#_ … _#) token
inside a comment.
* Use the values assigned to your variables using an “underscore pound equals”
(_#= … =#_) token.
–>
<div id=”ThreeLines“>
<!–#_
var encodedId = $htmlEncode(ctx.ClientControl.get_nextUniqueId() + “_3lines_”);
var linkURL = $getItemValue(ctx, “Link URL”);
linkURL.overrideValueRenderer($urlHtmlEncode);
var iconURL = Srch.ContentBySearch.getIconSourceFromItem(ctx.CurrentItem);
var line1 = $getItemValue(ctx, “Line 1”);
var line2 = $getItemValue(ctx, “Line 2”);
var line3 = $getItemValue(ctx, “Line 3”);
line1.overrideValueRenderer($contentLineText);
line2.overrideValueRenderer($contentLineText);
line3.overrideValueRenderer($contentLineText);
var containerId = encodedId + “container”;
var pictureLinkId = encodedId + “pictureLink”;
var pictureId = encodedId + “picture”;
var dataContainerId = encodedId + “dataContainer”;
var line1LinkId = encodedId + “line1Link”;
var line1Id = encodedId + “line1”;
var line2Id = encodedId + “line2”;
var line3Id = encodedId + “line3”;
_#–>
<div class=”cbs-Item” id=”_#= containerId =#_” data-displaytemplate=”Item2Lines”>
<a class=”cbs-ItemLink” title=”_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_” id=”_#= pictureLinkId =#_”>
<img class=”cbs-Thumbnail” src=”_#= $urlHtmlEncode(iconURL) =#_” alt=”_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_” id=”_#= pictureId =#_” />
</a>
<div class=”cbs-Detail” id=”_#= dataContainerId =#_”>
<a class=”cbs-Line1Link ms-noWrap ms-displayBlock” href=”_#= linkURL =#_” title=”_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_” id=”_#= line1LinkId =#_”>_#= line1 =#_</a>
<!–#_
if(!line2.isEmpty)
{
_#–>
<div class=”cbs-Line2 ms-noWrap” title=”_#= $htmlEncode(line2.defaultValueRenderer(line2)) =#_” id=”_#= line2Id =#_”>_#= line2 =#_</div>
<!–#_
}
_#–>
<!–#_
if(!line3.isEmpty)
{
_#–>
<div class=”cbs-Line2 ms-noWrap” title=”_#= $htmlEncode(line2.defaultValueRenderer(line3)) =#_” id=”_#= line3Id =#_”>_#= line3 =#_</div>
<!–#_
}
_#–>
</div>
</div>
</div>
</body>
</html>

6.  Save the edited “Item_ThreeLines.html” file. Check In the file and publish as a Major Version.

7.  If updated correctly, the new Display Template will appear in the “Content Search” Web Part properties. Select the display template name e.g. “Three lines”, as shown below:

Content Search Web Part Display Template Properties

8.  Expand the “Property Mappings” and tick the “Change the mapping of managed properties…” tick box. Note that a Link URL and Line 1, Line 2, and Line 3 appear based on the HTML changes. Click the drop-down menus to select available managed properties. On my example I have chosen to display a custom managed property called “DEVBMSID”, Title and UIVersionStringOWSTEXT (Version Number).

9.  To ensure that the Content Search Web Part only displays relevant documents click on the “Change Query” button in the “Search Criteria” section. Use the Quick Mode query builder or switch to Advanced Mode and enter search syntax – see example below:

Content Search – Build Your Query

10. You can test the results before clicking the “OK” button to save the search. Note: Refiners and Sorting can also be defined.

11. Ensure the “Number of items to show” is set to a suitable number – otherwise not all search results will be displayed.

12. Finally click on the Content Search Web Part properties “OK” button to save all settings.

 

Hiding the first global navigation heading in SharePoint 2013

Slightly different CSS has to be added to hide the first global navigation heading in SharePoint 2013.

/*

hide the top nav home link

N.B. this will hide all managed metadata navigation will probably require javascript as well

*/

.ms-core-listMenu-horizontalBox > .ms-core-listMenu-root > li > a {

                display:none;

}

 

This will prevent the site collection name appearing as the first global heading link.

Note: This will not work if you are using Term-driven Navigation.

SharePoint 2013 Search Results Not Displaying All Results

I have been playing with the “Search Results” Web Part that appears in SharePoint 2013. I was attempting to search for three different content types and display the results. The new Query Builder allowed me to quickly build the query:

ContentType:”Memo” ContentType:”Policy” ContentType:”Procedures”

The “Test Query” button correctly displays 4 results. However, when the Web Part is saved only 2 results are displayed. Why could this be?

After a bit of routing around I found this blog post that resolved the problem : http://blogs.perficient.com/microsoft/2013/04/sharepoint-2013-search-not-display-all-results/

SharePoint Search attempts to trim the results when it sees similar content. I was using sample documents with almost identical content, so 2 of the results were not being displayed!

To overcome this you need to:

1. Export the Search Results Web Part from your page.

2. Open the .Web Part file in your e.g. Notepad++.

3. Search for “TrimDuplicates” – mine was on line 42.

4. Change the TrimDuplicates property from True to False.

5. Upload the updated Web Part.

6. Add the Web Part to your page.

It should now work.

Create a SharePoint content database in SQL Server

There are several ways of creating a SharePoint content database. First you can create a content database via the SharePoint Central Administration console. However this approach disregards any settings the DBA may wish to employ based on the SQL Server model database. Even if the “Model” system database is configured in SQL Server, the content database will not pick up the autogrowth settings. So the preferred approach for IT Pros is for the DBA to first create the content databases in SQL Server itself. The System Administrator can then create web apps and site collections that reference these databases. Taking this approach, what options are available?

1)      Use PowerShell scripts to create the content databases.

2)      Create the databases in SQL Server directly.

For Option 2, I recommend you watch the following video that explains step-by-step how to do this – see “Tuning SQL Server 2012 for SharePoint 2013 – Best Practices for SQL Server Database Settings” at http://channel9.msdn.com/Series/Tuning-SQL-Server-2012-for-SharePoint-2013/Tuning-SQL-Server-2012-for-SharePoint-2013-02-Best-Practices-for-SQL-Server-Database-Settings#time=20m24s

Things to bear in mind:

1)      Set the Model system database with your default Initial database and log Initial Size and Autogrowth configuration settings:

2)      Ensure the Model system database “Options” Recovery model is set to “Full” on the Production Server:

3)      Set the correct Collation, so that SharePoint web apps and site collection can pair up with the content databases.

4)      Now the SharePoint System Administrator can start creating site collections in Central Admin or PowerShell and pair with the newly created content databases.

Note: Ensure that if content databases are taken “Offline” (to avoid site collection pairing) that they are brought back to “Ready” when done; otherwise search crawls etc. will exclude the content databases. You can also set the maximum number of site collections on a content database to ensure that a new site collection does not pair with the content database.

The PowerShell approach is explained further in the following references:

Reference Link
SQL Server PowerShell Provider http://msdn.microsoft.com/en-us/library/cc281947.aspx
Add content databases in SharePoint 2013 http://technet.microsoft.com/en-us/library/cc825314.aspx
SQL Server Community (Toad World) http://www.toadworld.com/platforms/sql-server/default.aspx

 

Where’s the Library or List View menu in SharePoint 2013?

The SharePoint 2013 interface has changed. This means changing the “view” on a list or library is now made by clicking on the view names or the “…” ellipsis to access further views:

 

Things to note:

Only 3 views are shown as text. Other views need to be selected from the ellipsis.

If the “Style” is changed on the view from “Default” to e.g. “Shaded” the view panel and the “Find an item …” will disappear.

SharePoint Roles & Responsibilities – A Quick Overview

It is often not fully recognised how many different roles need to be appointed to manage a SharePoint deployment. Below is a quick list of common roles and responsibilities:

Role Responsibility Comments
SharePoint System Administrator Responsible for SharePoint Farm administration, including installation/deployment, managing Web Apps, Content Databases, Site Collections, Security, Backups etc. Typically a 1FTE IT function specific to SharePoint administration.
Active Directory (AD) Administrator Responsible for managing Active Directory OU’s, User & Groups, Distribution Lists etc. IT function – an existing role that is involved in the planning and administration of AD for SharePoint. The role may extend to security management in general using products like Microsoft’s Forefront Identity Manager (FIM), Claims-based authentication, and Anti-Virus protection.
Database Administrator (DBA) Responsible for managing SQL Server environment, including creation and monitoring of content databases, log files etc. IT function – typically an existing role that is involved in the planning, administration and monitoring of SharePoint SQL Server database tables.
Infrastructure Administrator Responsible for servers and network infrastructure. IT function – an existing role that is involved in the planning, administration and monitoring of SharePoint servers and network infrastructure.
Business Analyst Responsible for defining business requirements. IT or Business function – produces functional requirements.
SharePoint Architect Responsible for designing and configuring SharePoint site structure, metadata architecture, page layouts, security model etc. Works closely with SharePoint Developers translating requirements to solutions. IT function – needs a thorough understanding of SharePoint (admin, developing functions) including when and how new components and web parts should be developed.
Technical Architect Responsible for designing and configuring SharePoint server farm to support business requirements. IT function – performance monitoring, capacity planning, server maintenance etc.
Search Administrator Responsible for administering SharePoint Search – including content sources, result sources, search schema, index crawls, Search Centre configuration etc. IT function – may be part of SharePoint System Administrator role (depending on scale and type of deployment).
Backup/Restore Administrator Disaster Recovery Planning – Management of routine database backups, monitoring and database restores. May extend to management of file systems if Remote Blob Storage (RBS) is used. IT function – may be part of SharePoint System Administrator role, or DBA, or Infrastructure Administrator role (depending on scale and type of deployment).
SharePoint Developer Broad software development role – including custom application development for sandboxed solutions, systems integration, custom web parts and component development. IT function – experience typically includes Asp.Net, C#.Net, Ajax, JavaScript etc.
SharePoint Web Designer Customization of the SharePoint solution such as re-branding, using products such as SharePoint Designer – some programming skills. IT function – experience typically includes HTML, style sheet, CAML, XML, XSLT, JavaScript etc.
Site Collection Administrator Responsible for administering site collection – may include management of permissions, web design, search, content types & columns, monitoring/reporting, functions etc. IT or Business Function – requires Site Administration and Governance training.
Site Owner Similar responsibility as Site Collection Administrator, but specific to the site or workspace. For example, Site Owner may be a Project manager responsible for their project workspace. Typically a Business Function – may be the same person as Site Collection Administrator.
Power User Creates and configures lists, libraries, web parts, permissions, features etc. Good all-round knowledge of SharePoint product capabilities. Often allowed to create sub-sites or workspaces. Typically an IT savvy Business user, who acts as a local department or team “champion”. Fully conversant in SharePoint Governance policies & standards.
End-User Information workers. Those who use SharePoint on a day-to-day basis, also working with other products & technologies such as MS Office and scanning solutions. Business users who adopt SharePoint for the collaboration and sharing of information.
Trainer Responsible for training different roles how to administer and use SharePoint, in line with agreed SharePoint Governance directives. In-house trainers or external training organisation, such as Combined Knowledge or Learning Tree. Tailored training programmes for different roles is normally required, backed up by related media.
Tester Responsible for testing custom developed solutions on a Sandbox, Development/Staging environment. Authorise deployment to SharePoint Production system. IT or Business function – depending on who has defined the requirements.
Support Responsible for providing support to different roles, including help Desk support to end-users, floor-walking etc. Usually share knowledge in FAQ forums and feedback to Training/Governance process. Commonly work to agreed SLA’s to provide efficient response to requests or queries.

 

For smaller deployments one person may wear several “hats”, but it remains important that each individual understands their responsibilities and governance controls are in place to help protect SharePoint’s evolvement, in alignment with business needs.

A SharePoint Governance Board should also be appointed, with contributors from IT and the business – including senior stakeholders. The Governance Board should meet regularly to review how SharePoint is being used, address new requirements, and update standards, policies and procedures. It is recommended that the Board includes a rotating membership from the Business, so that an effective feedback loop can be incorporated into the governance process.

I usually define an organisation’s roles & responsibilities in a RACI Matrix and map particular activities or tasks to defined Governance Standards and Policies, using a SharePoint Governance Team Site I have developed over the years.

See Combined Knowledge’s SharePoint training programme here: http://www.combined-knowledge.com/index.html

Should I use a Host-Named Site Collection (HNSC)?

New to Microsoft SharePoint 2013 (SP13) is “Host-Named Site Collections” (HNSC), replacing host-headers and offering an alternative to path-based site collection addressing (managed path – explicit or wildcard inclusion).

Microsoft encourage new SP13 deployments to create HNSC because they create a unique URL for each site collection, reducing URL length whilst allowing multiple URL’s to point to the same site collection with multiple claims-based authentication methods to the same web application. To read up more about HNSC see http://technet.microsoft.com/en-us/library/cc424952.aspx

Note: HNSC’s can only be created using PowerShell, i.e. there is NO configuration option in Central Admin. There are three PowerShell commands that are used for creating and managing HNSC’s:

  • Get-SPSiteURL – See all the URL’s and associated zones for a site collection.
  • Set-SPSiteURL – Add or amend a URL mapping for a site collection.
  • Remove-SPSiteURL – Remove a URL mapping from a site collection.

Here is a sample PowerShell script that creates a new host name http://finance.mycompany.com on the web application http://teams.mycompany.com

New-SPSite –Url http://finance.mycompany.com –OwnerAlias “mydomain\driscollm” –HostHeaderWebApplication http://teams.mycompany.com –Template STS#0

 

The Template “STS#0” above relates to the “Team Site” site collection template. To identify the site collection (web) template to use in the above PowerShell type in the following:

Get-SPWebTemplate

 

The results should appear similar to below:

References can also be found on the Web, for example see http://www.funwithsharepoint.com/Lists/Posts/Post.aspx?ID=2

To list the available site collection templates for a particular Web App you can also type the following PowerShell:

Get-SPWeb http://teams |   %{$_.GetAvailableWebTemplates(1033)} | select title, name

When the HNSC PowerShell script has successfully run, you will not initially be able to access the new site. This is because you next need to go to Internet Information Services (IIS) Manager, expand Sites and left-click to highlight the top-level web application site collection. Click Edit Bindings (right-side) and add the HNSC name (e.g. mycompany.com)  in the Host Name. Then in DNS Manager add a New Host (A or AAA) (e.g. finance.mycompany.com) to the associated forward lookup zone with the Port 80 IP address. Try entering the new HNSC name in the web browser – it should now connect successfully to the new site collection.