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

Listing SQL Server configuration settings


This recipe walks through how to list SQL Server configurable and nonconfigurable instance settings using PowerShell.

How to do it...

Let's look at the steps involved in listing SQL Server configuration settings:

  1. Open PowerShell ISE as administrator.

  2. Import the SQLPS module and create a new SMO Server Object:

    #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

    To explore what members and methods are included in the SMO server, use the following:

    #Explore: get all properties available for a server object
    #see http://msdn.microsoft.com/en-us/library/ms212724.aspx
    
    $server |
    Get-Member |
    Where-Object MemberType -eq "Property"

    First, let's explore the Information class.

    #The Information class lists nonconfigurable
    #instance settings, like BuildNumber,
    #OSVersion, ProductLevel etc...