Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Adding full-text catalog


In this recipe, we will create a full-text catalog.

Getting ready

In this recipe, a full-text search component needs to be installed on your SQL Server instance.

Run the script B04525 - Ch06 - 10 - Adding Full-Text Catalog - Prep.ps1 to ready the database we will use in this recipe. This script creates a database called FullTextCatalogDB that contains a table called Documents.

How to do it...

Let's take a look at the steps to create a full-text catalog:

  1. Open PowerShell ISE as an administrator.

  2. Import the SQLPS module and create a new SMO Server object as follows:

    #import SQL Server module
    Import-Module SQLPS –DisableNameChecking
    
    $instanceName = "localhost"
    $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName
  3. Add the following script and run it:

    $databaseName = "FullTextCatalogDB"
    $db = $server.Databases[$databaseName]
    
    $catalogName = "FTC"
    
    $ftc = New-Object -TypeName Microsoft.SqlServer.Management.Smo.FullTextCatalog -ArgumentList...