How it works...
You would have seen the use of #region and #endregion here for the first time in this book. This construct is used to enable code folding in code editors, as well as to be simple logical boundaries to visually help readers understand the script. They are by no means necessary.
The first region in the script merely backs up the three files in order to restore them if need be, given that using variables for this seems a little too volatile.
The three cmdlets we use in this recipe are Set-Content, Add-Content, and Clear-Content. The Set-Content cmdlet replaces the contents in a file (or files, with the paths separated by commas; the Path parameter in all the three cmdlets accepts a string array as input).
The Add-Content cmdlet ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access