liveBook · Manning

SQL Server

As explained in Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

SQL Server is Microsoft's relational database management system for storing, querying, and managing structured data.

SQL Server provides durable storage for structured data collected by automation. PowerShell commands can create tables, insert objects, retrieve rows, and support scheduled reporting through SSRS. section 26.3 section 26.6

A practical PowerShell integration follows a repeatable pattern:

  • Open a System.Data.SqlClient.SqlConnection with a connection string, then close it after the operation. section 26.3
  • Build SQL in a here-string, create a SqlCommand, assign its connection and command text, and execute it. section 26.3
  • Read query results with a DataReader and translate database column names into useful PowerShell object properties. section 26.5

Disk inventory database

A New-DiskInfoSQLTable command creates a diskinfo table only when needed, while Import-DiskInfoFromSQL selects rows ordered by DateAdded and returns disk objects with properties such as ComputerName, Drive, Size, and FreeSpace.

How Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools covers it

How deep it goes
Demonstrates connections, commands, table creation, queries, readers, and property translation, but does not develop database administration.
Examples
Uses disk-inventory objects, a diskinfo table, conditional creation, row retrieval, and translated Size and Drive properties.
What it assumes
Assumes PowerShell toolmaking and basic SQL familiarity while demonstrating SqlClient connection and command mechanics.
What you can do after
Build it from scratch as PowerShell commands that store inventory objects, query rows, and feed automated reports.
How it connects
Connects SQL Server with PowerShell modules, .NET data-access classes, SQL queries, SSRS, scheduled tasks, and DBATools.

Also explained in

Compare how 3 books explain SQL Server →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools. The section links point to the parts of the book it draws on.