mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-20 03:37:56 +02:00
Renamed to new-powershell-script.ps1
This commit is contained in:
parent
29d27eec18
commit
f177f22cf8
@ -1,12 +1,12 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Creates a new PowerShell script
|
||||
Creates a PowerShell script
|
||||
.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
|
||||
Specifies the path and new filename
|
||||
Specifies the path and new filename ("bot.ps1" by default)
|
||||
.EXAMPLE
|
||||
PS> ./new-script.ps1 bot.ps1
|
||||
PS> ./new-powershell-script.ps1
|
||||
✅ New PowerShell script 'bot.ps1' created from template 'PowerShell.ps1'.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -14,16 +14,14 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$path = "")
|
||||
param([string]$path = "bot.ps1")
|
||||
|
||||
try {
|
||||
if ($path -eq "" ) { $path = Read-Host "Enter the new filename" }
|
||||
|
||||
$pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/PowerShell.ps1"
|
||||
$pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/New.ps1"
|
||||
Copy-Item $pathToTemplate "$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
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
Loading…
x
Reference in New Issue
Block a user