Skip to content

Commit 05541a5

Browse files
Improves examples
1 parent aeaf529 commit 05541a5

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

ScriptBlocks/Example-Finally.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name)
1515
try {
1616
Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name)
1717

18+
# Put here code which you want to execute at the Finally step.
19+
20+
# In the example below, we check if monitoring enabled for the host and, if needed, we turn it back on.
21+
# As with the PreRestore step, here we use the $HostDowntime variable to pass downtime objects between step scripts.
22+
1823
$HostDowntime = ($Variables | Where-Object -FilterScript {$_.Name -eq 'HostDowntime'}).Value
1924
Write-Debug -Message ('$HostDowntime: {0}' -f $HostDowntime)
2025
$YourFavoriteMonitoringSystemComputerName = ($Variables | Where-Object -FilterScript {$_.Name -eq 'YourFavoriteMonitoringSystemComputerName'}).Value

ScriptBlocks/Example-PostClear.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name)
1717
try {
1818
Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name)
1919

20+
# Put here code which you want to execute at the PostClear step.
21+
22+
# The example below temporarily disables monitoring (sets downtime) of the host in a fictional Your Favorite Monitoring System
23+
# Note, that is this fictious monitoring system, we need the downtime object to enable monitoring of the host later.
24+
# So in order to keep it, we save it into a variable ($HostDowntime) and pass that variable to the caller function.
25+
# Later, on the PreRestore step, we'll use that $HostDowntime object to enable monitoring back.
26+
2027
$CallerName = ($Variables | Where-Object -FilterScript {$_.Name -eq 'CallerName'}).Value
2128
Write-Debug -Message ('$CallerName = ''{0}''' -f $CallerName)
2229

ScriptBlocks/Example-PostRestore.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name)
1414
try {
1515
Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name)
1616

17+
# Put here code which you want to execute at the PostRestore step.
18+
1719
Write-Debug -Message ('EXIT TRY {0}' -f $MyInvocation.MyCommand.Name)
1820
}
1921
catch {

ScriptBlocks/Example-PreClear.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name)
1414
try {
1515
Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name)
1616

17+
# Put here code which you want to execute at the PreClear step.
18+
1719
Write-Debug -Message ('EXIT TRY {0}' -f $MyInvocation.MyCommand.Name)
1820
}
1921
catch {

ScriptBlocks/Example-PreRestore.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name)
1515
try {
1616
Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name)
1717

18+
# Put here code which you want to execute at the PreRestore step.
19+
20+
# The example below enables back monitoring of the host in a fictional Your Favorite Monitoring System.
21+
# To remove the downtime from our host, we use a downtime object from the PostClear step ($HostDowntime).
22+
1823
$HostDowntime = ($Variables | Where-Object -FilterScript {$_.Name -eq 'HostDowntime'}).Value
1924
Write-Debug -Message ('$HostDowntime: {0}' -f $HostDowntime)
2025
$YourFavoriteMonitoringSystemComputerName = ($Variables | Where-Object -FilterScript {$_.Name -eq 'YourFavoriteMonitoringSystemComputerName'}).Value

ScriptBlocks/Example-Test.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name)
1414
try {
1515
Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name)
1616

17+
# Put here code which you want to execute at the Test step.
18+
1719
Write-Debug -Message '$true'
18-
$true # Really, you should put some commands here instead, which will test your node.
20+
$true # Really, you should put some commands here instead, which will test readiness of your node.
1921

2022
Write-Debug -Message ('EXIT TRY {0}' -f $MyInvocation.MyCommand.Name)
2123
}

0 commit comments

Comments
 (0)