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 installed hotfixes and Service Packs


In this recipe, we will check which Service Pack and hotfixes/patches are installed on our server.

How to do it...

Let's explore the ways to list hotfixes and Service Packs:

  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 list the version of SQL Server and Service Pack level, add the following script and run:

    #the version format is:
    #major.minor.build.buildminor
    #this should tell you collectively at what
    #level your install is
    $server.Information.VersionString
    
    #version of SQL Server:
    #'RTM' = Original release version
    #'SPn' = Service pack version
    #'CTP', = Community Technology Preview version
    $server.Information.ProductLevel
    
    #to get hotfixes/updates/patches, we can...