Templates/NewScript/src/Script.ps1

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<#PSScriptInfo
    .VERSION <%=$PLASTER_PARAM_Version%>
    .GUID <%=$PLASTER_Guid1%>
    .AUTHOR <%=$PLASTER_PARAM_FullName%>
    .COMPANYNAME
    .COPYRIGHT
    .TAGS
    .LICENSEURI
    .PROJECTURI
    .ICONURI
    .EXTERNALMODULEDEPENDENCIES
    .REQUIREDSCRIPTS
    .EXTERNALSCRIPTDEPENDENCIES
    .RELEASENOTES
    .DESCRIPTION
    <%=$PLASTER_PARAM_ScriptDesc%>
#>


[cmdletbinding()]
param()

# --------------------------- User Defined Variables --------------------------
# Edit these variables as needed

#
# <- VARIABLES HERE ->
#

###############################################################################
# DO NOT MODIFY BEYOND THIS POINT! #
###############################################################################

# Track running time.
$StopWatch = [ordered]@{
    Total = [System.Diagnostics.Stopwatch]::StartNew()
}

# ------------------------------ Static Variables -----------------------------

#
# <- VARIABLES HERE ->
#

# ------------------------------ Helper Functions -----------------------------

# Track step time.
$StopWatch.LoadFunctions = [System.Diagnostics.Stopwatch]::StartNew()

#
# <- FUNCTIONS HERE ->
#

# Stop step timer.
$StopWatch.LoadFunctions.Stop()

# ------------------------------- Script Logic --------------------------------

# Track step time.
$StopWatch.ScriptLogic = [System.Diagnostics.Stopwatch]::StartNew()

#
# <- LOGIC HERE ->
#

# Stop step timer.
$StopWatch.ScriptLogic.Stop()

# Compute and display elapsed run time (Verbose stream.)
$StopWatch.Total.Stop()
$StepTimes = @(
    $StopWatch.Keys | Where-Object { $_ -ne 'Total' } | ForEach-Object { [pscustomobject]@{ Step = $_ ; ElapsedTime = $StopWatch.Item($_).Elapsed.ToString()} }
)
$StepTimes | Out-String -Stream | Where-Object { $_ -ne "" } | Write-Verbose
Write-Verbose ""
Write-Verbose "TOTAL $($Stopwatch.Total.Elapsed.ToString())"