Book Image

PowerShell for SQL Server Essentials

By : Donabel Santos
Book Image

PowerShell for SQL Server Essentials

By: Donabel Santos

Overview of this book

Table of Contents (15 chapters)
PowerShell for SQL Server Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Implementing Reusability with Functions and Modules
Index

Hotfixes and service packs


We can use PowerShell to figure out the operating system the server is running on and on which service pack. The Win32_OperatingSystem WMI class contains the OS service pack information. The following script performs this query:

#current server name
$servername = "ROGUE"

Get-WmiObject -Class Win32_OperatingSystem `
              -ComputerName $servername |
Select-Object CSName, Caption,
       ServicePackMajorVersion, 
       ServicePackMinorVersion |
Format-List

Your result should include the computer name and the service pack information. If you get a zero (0) value, it means no service packs have been applied to the system yet.

In addition to service pack information, you can also use PowerShell to query which hotfixes and updates have been installed on the system. You can use the Win32_QuickFixEngineering WMI class to do this. The following is an example of how you can use this class:

#current server name
$servername = "ROGUE"

Get-WmiObject -Class Win32_QuickFixEngineering...