-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_Template.ps1
More file actions
76 lines (61 loc) · 1.61 KB
/
Copy path_Template.ps1
File metadata and controls
76 lines (61 loc) · 1.61 KB
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
76
#Requires -Version 7.0
<#
.SYNOPSIS
One-line summary of what this script does.
.DESCRIPTION
Longer description: what it automates, its prerequisites (modules, CLIs,
authentication) and any side effects it has on the environment.
.PARAMETER Name
Describe each parameter. Repeat this section for every parameter.
.INPUTS
None. Or describe the objects accepted from the pipeline.
.OUTPUTS
None. Or describe the objects / files produced.
.EXAMPLE
./Verb-Noun.ps1 -Name 'value'
Describe what this example does.
.NOTES
Author: Sebastian Gräf
Repo: https://github.com/segraef/Scripts
Version history is tracked in git, not in this header.
#>
[CmdletBinding(SupportsShouldProcess)]
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$Name,
[Parameter()]
[securestring]$Secret
)
#region Initialisation
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
Import-Module "$PSScriptRoot/Write-Log.psm1" -Force
#endregion
#region Functions
function Invoke-Example {
[CmdletBinding(SupportsShouldProcess)]
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$Name
)
Write-Log "Processing '$Name'."
if ($PSCmdlet.ShouldProcess($Name, 'Process')) {
try {
Write-Output "Hello, $Name."
}
catch {
Write-Log -Message "Failed to process '$Name'." -ErrorRecord $_
throw
}
}
}
#endregion
#region Execution
Write-Log "Executing $($MyInvocation.MyCommand.Name)."
Invoke-Example -Name $Name
Write-Log "Finished $($MyInvocation.MyCommand.Name)."
#endregion