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

Enabling FileStream


This recipe explains how to enable FileStream in SQL Server.

How to do it...

Let's take a look at the steps to enable FileStream in SQL Server:

  1. Open PowerShell ISE as an administrator.

  2. Import the SQLPS module as follows:

    #import SQL Server module
    Import-Module SQLPS -DisableNameChecking
  3. Add the following script and run it:

    $instanceName = "localhost"
    $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName
    
    <#
    These are the FileStreamLevel Enumeration values:
    Disabled
    TSqlAccess
    TSqlFullFileSystemAccess
    TSqlLocalFileSystemAccess
    #>
    
    #enable
    $server.Configuration.FilestreamAccessLevel.ConfigValue = [Microsoft.SqlServer.Management.Smo.FileStreamLevel]::TSqlLocalFileSystemAccess
    $server.Alter()

How it works...

If you've ever had to maintain folders with images or videos in them, and you had to reference the file paths (or URLs) and other metadata from SQL Server, you might have encountered challenges in keeping these two synchronized...