mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Add new-script.ps1
This commit is contained in:
26
Scripts/new-script.ps1
Executable file
26
Scripts/new-script.ps1
Executable file
@ -0,0 +1,26 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
new-script.ps1 [<filename>]
|
||||
.DESCRIPTION
|
||||
Creates a new PowerShell script.
|
||||
.EXAMPLE
|
||||
PS> .\new-script.ps1 myscript.ps1
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
param([string]$filename = "")
|
||||
|
||||
try {
|
||||
if ($filename -eq "" ) { $shortcut = read-host "Enter the new filename" }
|
||||
|
||||
copy-item "$PSScriptRoot/../data/template.ps1" "$filename"
|
||||
|
||||
"✔️ created new PowerShell script $filename"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#requires -version 4
|
||||
<#
|
||||
.SYNOPSIS
|
||||
← enter overview of script here
|
||||
.DESCRIPTION
|
||||
← enter brief description of script here
|
||||
.INPUTS
|
||||
← enter inputs here (if any, otherwise state None)
|
||||
.OUTPUTS
|
||||
← enter outputs here (if any, otherwise state None)
|
||||
.EXAMPLE
|
||||
PS> .\template.ps1 ← enter example here (repeat this attribute for more than one example)
|
||||
.NOTES
|
||||
Author: ← enter full name here
|
||||
License: ← enter license here
|
||||
.LINK
|
||||
← enter URL here
|
||||
#>
|
||||
|
||||
param() # ← enter script parameters here
|
||||
|
||||
# ← enter functions here
|
||||
|
||||
try {
|
||||
# ← enter instructions here
|
||||
|
||||
"✔️ Done."
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user