forked from LeeHolmes/PowerShellCookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTidyModule.psm1
More file actions
32 lines (25 loc) · 713 Bytes
/
TidyModule.psm1
File metadata and controls
32 lines (25 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
##############################################################################
##
## TidyModule.psm1
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################
<#
.SYNOPSIS
Demonstrates how to handle cleanup tasks when a module is removed
.EXAMPLE
PS > Import-Module TidyModule
PS > $TidyModuleStatus
Initialized
PS > Remove-Module TidyModule
PS > $TidyModuleStatus
Cleaned Up
#>
## Perform some initialization tasks
$GLOBAL:TidyModuleStatus = "Initialized"
## Register for cleanup
$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
$GLOBAL:TidyModuleStatus = "Cleaned Up"
}