November 2018
Intermediate to advanced
566 pages
17h 15m
English
Members of a module share private state. In the case of simple script modules like the one in this recipe, it is not quite necessary to perform explicit cleanup. However, it is good to know how it can be done.
There are two aspects to consider:
To perform a task (or tasks) upon running the Remove-Module cmdlet on the module in question, you must create a script block with the cmdlets that should be run during the module removal. This script block is then assigned to the $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove object. In our case, we do not perform a real cleanup; we simply display ...
Read now
Unlock full access