O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SQL Server-Specific Tasks

Before jumping into more hardcore SQL Server PowerShell features, let’s briefly look at the SQL Server event log. Fortunately, the log simply contains text-based files, which PowerShell can read. You could use the Get-Content cmdlet to view the entire log, but instead you can use the Select-String cmdlet to look for a specific string or pattern in the error log file. First, you change the current location to the SQL Server log directory:

PS>Set-Location "C:\Program Files\Microsoft SQL Server"PS>Set-Location (join-path $pwd "MSSQL11.MSSQLSERVER\MSSQL\Log")PS>Select-String "error" ERRORLOG

The PowerShell prompt in the preceding example is simply a generic one because the preceding commands ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required