code-snippets/docs/powershell/basic-template.md
Liam Pietralla 8ad5845efc
Some checks failed
Build, Test & Publish / Build and Publish Container Image (push) Has been cancelled
Build, Test & Publish / Deploy to Infrastructure (push) Has been cancelled
Build, Test & Publish / Build (push) Has been cancelled
initial commit
2024-09-05 13:54:08 +10:00

43 lines
956 B
Markdown

# PowerShell Script Template
This is a basic template for a PowerShell script, that can be used as a starting point for your own scripts.
## Prerequisites
* PowerShell 7.1 or higher
## Step 1: Create a new file
Create a new file with the extension `.ps1` and add the following content:
```powershell
<#
.SYNOPSIS
A short description of the script.
.DESCRIPTION
A longer description of the script.
This description can span multiple lines.
.PARAMETER SampleText
A sample parameter. This should describe what the parameter is for and any restrictions on it.
.EXAMPLE
-SampleText 'Hello World!'
.NOTES
Author: Liam Pietralla
Last Update: 2023-04-13
#>
param(
[parameter(Mandatory=$true)]
[string] $SampleText
)
filter timestamp {"[$(Get-Date -Format G)]: $_"}
Write-Output 'Script started.' | timestamp
# Your script goes here
Write-Output $SampleText | timestamp
Write-Output 'Script finished.' | timestamp
```