-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.ps1
More file actions
65 lines (56 loc) · 2.24 KB
/
Copy pathtemplate.ps1
File metadata and controls
65 lines (56 loc) · 2.24 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
<#
.SYNOPSIS
One sentence describing this script's purpose.
.DESCRIPTION
More detailed description of the script's purpose.
.EXAMPLE
.\template.ps1
Add additional .EXAMPLE blocks if the script can be run multiple ways.
.INPUTS
Describe any inputs required.
.OUTPUTS
Log file written to .\logs\<prefix>-yyyyMMdd-T-HHmmss.log
.NOTES
Execution: [Ad-Hoc | Scheduled Task]
Compatibility: PowerShell 5.1 and higher
Version: 1.0.0
# Versioning Guide:
# - Major (X.0.0): Significant logic or architecture changes.
# - Minor (1.X.0): New features or improvements.
# - Patch (1.0.X): Bug fixes and logging changes.
Change Log:
| Name | Date | Version | Change |
|--------------------|------------|---------|----------------|
| FirstName LastName | YYYY-MM-DD | 1.0.0 | Initial Commit |
#>
# ============================================================
# SECTION: Required Modules
# ============================================================
# Example: #Requires -Modules ActiveDirectory
# ============================================================
# SECTION: Global Variables
# ============================================================
$ScriptStartTime = Get-Date # Capture script start time for logging and duration calculation
$ExitCode = 0 # Default exit code, can be updated based on script logic
# ============================================================
# SECTION: Logger Configuration
# ============================================================
. "$PSScriptRoot\logger.ps1"
Initialize-Logging -Prefix "script-logs" -RetentionDays 7 -LogLevel "DEBUG" -ScriptPath $PSScriptRoot -ScriptStartTime $ScriptStartTime
# ============================================================
# SECTION: Main Logic
# ============================================================
try {
Clear-Host
# MAIN LOGIC GOES HERE - REPLACE THIS COMMENT WITH YOUR CODE
# ALL CALLED FUNCTIONS SHOULD USE Write-Log FOR CONSISTENT LOGGING
}
catch {
Write-Log "Error: $_" -Level "FATAL"
}
finally {
$duration = (Get-Date) - $ScriptStartTime
Write-Log "Script finished. Duration: $($duration.TotalSeconds) seconds." -Level "INFO"
Remove-OldLogs
exit $ExitCode
}