In this section, we'll discuss the steps to perform data formatting on the sample data:
- Define the variables.
- Prepare the database connection string.
- Instantiate the System.Data.SqlClient.SqlConnection .NET class library.
- Open the connection, and the instance will be ready to use.
- Prepare the SQL query to run on the defined connection.
- Create a subobject called $cmd for the main object $ConnStr.
- Execute the SQL using the ExecuteReader() method.
- Load the result set into the table variable.
- Format the output with the formatting cmdlets.
- The following script takes care of the aforementioned tasks. Now, save the following content in the /tmp/DataFormatSample.ps1 file:
#Define Input variables$dataSource = "10.2.6.50"#Define the ...