File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree File renamed without changes.
Original file line number Diff line number Diff line change 11<#
22. SYNOPSIS
3- Creates a new PowerShell script
3+ Creates a PowerShell script
44. DESCRIPTION
5- This PowerShell script creates a new PowerShell script file by using the template file at: ../data/templates/PowerShell .ps1.
5+ This PowerShell script creates a new PowerShell script file by using the template ../data/templates/New .ps1.
66. PARAMETER path
7- Specifies the path and new filename
7+ Specifies the path and new filename ("bot.ps1" by default)
88. EXAMPLE
9- PS> ./new-script.ps1 bot.ps1
9+ PS> ./new-powershell- script.ps1
1010 ✅ New PowerShell script 'bot.ps1' created from template 'PowerShell.ps1'.
1111. LINK
1212 https://github.com/fleschutz/PowerShell
1313. NOTES
1414 Author: Markus Fleschutz | License: CC0
1515#>
1616
17- param ([string ]$path = " " )
17+ param ([string ]$path = " bot.ps1 " )
1818
1919try {
20- if ($path -eq " " ) { $path = Read-Host " Enter the new filename" }
21-
22- $pathToTemplate = Resolve-Path " $PSScriptRoot /../data/templates/PowerShell.ps1"
20+ $pathToTemplate = Resolve-Path " $PSScriptRoot /../data/templates/New.ps1"
2321 Copy-Item $pathToTemplate " $path "
2422 if ($lastExitCode -ne 0 ) { throw " Can't copy to: $path " }
2523
26- " ✅ New PowerShell script '$path ' created from template 'PowerShell .ps1' ."
24+ " ✅ New '$path ' created ( from data/templates/New .ps1) ."
2725 exit 0 # success
2826} catch {
2927 " ⚠️ Error: $ ( $Error [0 ]) "
You can’t perform that action at this time.
0 commit comments