Last active
January 29, 2025 15:45
-
-
Save 9to5IT/18ff0ddf706ec23be997 to your computer and use it in GitHub Desktop.
PowerShell: Script Template Version 2 (without logging)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -version 4 | |
<# | |
.SYNOPSIS | |
<Overview of script> | |
.DESCRIPTION | |
<Brief description of script> | |
.PARAMETER <Parameter_Name> | |
<Brief description of parameter input required. Repeat this attribute if required> | |
.INPUTS | |
<Inputs if any, otherwise state None> | |
.OUTPUTS | |
<Outputs if any, otherwise state None> | |
.NOTES | |
Version: 1.0 | |
Author: <Name> | |
Creation Date: <Date> | |
Purpose/Change: Initial script development | |
.EXAMPLE | |
<Example explanation goes here> | |
<Example goes here. Repeat this attribute for more than one example> | |
#> | |
#---------------------------------------------------------[Script Parameters]------------------------------------------------------ | |
Param ( | |
#Script parameters go here | |
) | |
#---------------------------------------------------------[Initialisations]-------------------------------------------------------- | |
#Set Error Action to Silently Continue | |
$ErrorActionPreference = 'SilentlyContinue' | |
#Import Modules & Snap-ins | |
#----------------------------------------------------------[Declarations]---------------------------------------------------------- | |
#Any Global Declarations go here | |
#-----------------------------------------------------------[Functions]------------------------------------------------------------ | |
<# | |
Function <FunctionName> { | |
Param () | |
Begin { | |
Write-Host '<description of what is going on>...' | |
} | |
Process { | |
Try { | |
<code goes here> | |
} | |
Catch { | |
Write-Host -BackgroundColor Red "Error: $($_.Exception)" | |
Break | |
} | |
} | |
End { | |
If ($?) { | |
Write-Host 'Completed Successfully.' | |
Write-Host ' ' | |
} | |
} | |
} | |
#> | |
#-----------------------------------------------------------[Execution]------------------------------------------------------------ | |
#Script Execution goes here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment