The Word object model exposes Microsoft Word documents and application operations as COM automation objects. PowerShell can use it to create a document, populate structured content, insert images, update a table of contents, and save the result. section 9.5
Implementation starts by loading the Word COM object, creating a document, and loading the Word interop assemblies. Reusable functions then separate document structure from data collection: headings, object-to-table conversion, array-to-table conversion, and time-series graph insertion. section 9.5
$Selection.Tables.psobject.methods OverloadDefinitions ------------------- Table Item (int Index) Table AddOld (Range Range, int NumRows, int NumColumns) Table Add (Range Range, int NumRows, int NumColumns, Variant DefaultTableBehavior, Variant AutoFitBehavior)
Inspect a Word collection through PSObject when the collection is empty or Get-Member cannot inspect it. The listing exposes Add overloads, including the range, row count, column count, and behavioral enumerators required for a table. section 9.1.4
Table creation follows a small set of implementation decisions:
- Supply a range, row count, and column count to Tables.Add(). section 9.1.4
- Use named WdDefaultTableBehavior and WdAutoFitBehavior enum values instead of opaque integers. section 9.1.4
- Write content through individual cells such as $Table.Cell(1,1).Range.Text. section 9.1.4
Automated system report
A reusable report function can create a title from the computer name, add a table of contents, write operating-system, disk, and network tables, retrieve external IP data with Invoke-RestMethod, graph processor-time samples, insert the PNG with InlineShapes.AddPicture(), refresh the table of contents, and save the document. section 9.5
