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

Changing authentication mode


In this recipe, we will change SQL Server authentication mode.

Getting ready

Confirm which authentication mode your instance is running. Go to SQL Server Management Studio and log in to your instance. Once logged in, right-click on the instance and go to Properties | Security (this is similar to what we did in the previous recipe):

In this recipe, we will change the authentication mode from Integrated to Mixed. Feel free to do the reverse if your settings are different from what is presented in the preceding image.

How to do it...

Let's explore the steps required to complete the task:

  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
    
    #replace this with your instance name
    $instanceName = "localhost"
    $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName

    Add the following script and run:

    #according...