In chapter 4, you were introduced to some of the common dbatools parameters. You also learned how to gather information about databases on multiple instances. This chapter will focus on saving data to the place where SQL Server DBAs feel most comfortable keeping data: a table in a SQL Server database! You will learn a number of ways to write data to a SQL Server table using dbatools. This chapter will be good to keep in mind as you go through the book, because it’s likely you will want to save your PowerShell output to a SQL Server database.
But for now, let’s start with understanding PowerShell’s pipeline. The pipeline in PowerShell is a feature that you need to be familiar with to use PowerShell effectively. We are going to start with the pipeline because it enables us to write the output of any PowerShell command to SQL Server.
One of PowerShell’s most powerful functionalities is the pipeline. The pipeline enables you to easily pass output from one command to another without using a cumbersome foreach. You have already seen this in action in chapter 4 with $instances | Connect-DbaInstance. This takes the values in the $instances variable and pipes them to Connect-DbaInstance.