18 SQL server agent administration

 

Now that you’re familiar with how the SQL Server Agent Engine and PowerShell can best work together, we’ll discuss how dbatools can help you manage SQL Server Agent.

As we discussed in Chapter 1, the manual administration of SQL Server Agent Jobs can be very time-consuming, especially when you have many instances or many jobs to administer. This chapter provides all of the tools that you require to be able to administer your SQL Server Agent estate efficiently. You’ll learn how to gather all of the information about your SQL Server Agents, how to find a particular job in your estate easily, and you’ll also learn how to retrieve and display the Agent Job results and history.

We have waited to talk fully about the SQL Server Agent until this chapter (and the next one) for a couple of reasons. We wanted you to have some knowledge about dbatools commands and be comfortable with their structure at the command line before discussing scheduling them with SQL Server Agent. As we discussed in Chapter 1, we considered the order of the chapters as if we were DBAs starting to look at a new estate.

DBA’s are used to examining and administering the SQL Server Agent using SQL Server Management Studio (SSMS). dbatools enables you to perform the same tasks at the command line. Using the command line makes it easier to manage multiple objects or instances at once.

Figure 18.1. SQL Server Agent in SSMS
ssmsagent

18.1 Listing SQL Agent Information

18.1.1 SQL Agent Jobs

18.1.2 SQL Server Agent Alerts

18.1.3 Finding Specific Agent Jobs

18.2 Agent Job Results and History

18.2.1 Agent Job Results

18.2.2 Timeline

18.3 Hands On Lab