new-powershell-script
Creates a PowerShell script
#Requires -Version 5.1
param([string]$path = "bot.ps1")
try {
if (Test-Path "$path" -pathType leaf) { throw "File '$path' is already existing" }
$pathToTemplate = Resolve-Path "$PSScriptRoot/data/templates/New.ps1"
Copy-Item $pathToTemplate "$path"
if ($lastExitCode -ne 0) { throw "Can't copy to: $path" }
"✅ New '$path' created (from data/templates/New.ps1)."
exit 0
} catch {
throw
}Specifies the path and new filename ("bot.ps1" by default)