Until now your functions lived in script files. That is enough for a script, but not for a tool that others use, that has versions, and whose behavior a test pins down. This lesson
packages the office tool into a module, builds a package from it and writes tests with Pester, the test framework for PowerShell. At the end stands a test that proves what lesson
PS.3.1 promised: with -WhatIf, nothing happens.
All examples were run in PowerShell 7.6.9 on Windows, with Pester 5.9.1. PowerShell's messages appear in the language of your system; some here are German. Times and paths in the output are shortened where it says so.
The office tool: where it stands
From PS.3 you have a runbook that sets up a set of report folders and deletes old reports, both behind ShouldProcess. In this lesson we move it into a module OfficeTools with two
functions: Initialize-ReportFolder creates missing folders and reports for each one what happened; Remove-OldReport deletes files that are older than a number of days.