mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 17:14:28 +01:00
28 lines
701 B
PowerShell
Executable File
28 lines
701 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
new-script.ps1 [<filename>]
|
|
.DESCRIPTION
|
|
Creates a new PowerShell script file (by using template file ../Data/template.ps1).
|
|
.EXAMPLE
|
|
PS> ./new-script myscript.ps1
|
|
✔️ created new PowerShell script: 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 # success
|
|
} catch {
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
exit 1
|
|
}
|