Renamed to new-powershell-script.ps1

This commit is contained in:
Markus Fleschutz 2025-06-05 14:13:06 +02:00
parent 29d27eec18
commit f177f22cf8
2 changed files with 7 additions and 9 deletions

View File

@ -1,12 +1,12 @@
<# <#
.SYNOPSIS .SYNOPSIS
Creates a new PowerShell script Creates a PowerShell script
.DESCRIPTION .DESCRIPTION
This PowerShell script creates a new PowerShell script file by using the template file at: ../data/templates/PowerShell.ps1. This PowerShell script creates a new PowerShell script file by using the template ../data/templates/New.ps1.
.PARAMETER path .PARAMETER path
Specifies the path and new filename Specifies the path and new filename ("bot.ps1" by default)
.EXAMPLE .EXAMPLE
PS> ./new-script.ps1 bot.ps1 PS> ./new-powershell-script.ps1
New PowerShell script 'bot.ps1' created from template 'PowerShell.ps1'. New PowerShell script 'bot.ps1' created from template 'PowerShell.ps1'.
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
@ -14,16 +14,14 @@
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$path = "") param([string]$path = "bot.ps1")
try { try {
if ($path -eq "" ) { $path = Read-Host "Enter the new filename" } $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/New.ps1"
$pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/PowerShell.ps1"
Copy-Item $pathToTemplate "$path" Copy-Item $pathToTemplate "$path"
if ($lastExitCode -ne 0) { throw "Can't copy to: $path" } if ($lastExitCode -ne 0) { throw "Can't copy to: $path" }
"✅ New PowerShell script '$path' created from template 'PowerShell.ps1'." "✅ New '$path' created (from data/templates/New.ps1)."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0])" "⚠️ Error: $($Error[0])"