Skip to content

Commit ec9253f

Browse files
committed
Add new-script.ps1
1 parent 3308c45 commit ec9253f

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

Data/scripts.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ pull-repo.ps1, pulls updates for the current/given Git repository (including sub
177177
pull-repos.ps1, pulls updates for all Git repositories under the current/given directory (including submodules)
178178
query-smart-data.ps1, queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
179179
new-email.ps1, starts the default email client to write a new email
180+
new-script.ps1, creates a new PowerShell script
180181
reboot.ps1, reboots the local computer (needs admin rights)
181182
reboot-fritzbox.ps1, reboots the FRITZ!box device
182183
remove-empty-dirs.ps1, removes empty subfolders within the given directory tree
@@ -217,7 +218,6 @@ switch-shelly1.ps1, switches a Shelly1 device in the local network
217218
sync-repo.ps1, synchronizes a Git repository by push & pull (including submodules)
218219
take-screenshot.ps1, takes a single screenshot
219220
take-screenshots.ps1, takes multiple screenshots
220-
template.ps1, copy this template PowerShell script to write a new one
221221
translate-file.ps1, translates the given text file into another language
222222
translate-files.ps1, translates the given text files into any supported language
223223
translate-text.ps1, translates the given text into other languages
File renamed without changes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ Mega Collection of PowerShell Scripts
227227
| [list-modules.ps1](Scripts/list-modules.ps1) | Lists the PowerShell modules | [Manual](Docs/list-modules.ps1.md) |
228228
| [list-profiles.ps1](Scripts/list-profiles.ps1) | Lists your PowerShell profiles | [Manual](Docs/list-profiles.ps1.md) |
229229
| [list-scripts.ps1](Scripts/list-scripts.ps1) | Lists all PowerShell scripts in this repository | [Manual](Docs/list-scripts.ps1.md) |
230+
| [new-script.ps1](Scripts/new-script.ps1) | Creates a new PowerShell script | [Manual](Docs/new-script.ps1.md) |
230231
| [set-profile.ps1](Scripts/set-profile.ps1) | Updates your PowerShell user profile | [Manual](Docs/set-profile.ps1.md) |
231-
| [template.ps1](Scripts/template.ps1) | Copy this template PowerShell script to write a new one | [Manual](Docs/template.ps1.md) |
232232

233233
🛒 Various PowerShell Scripts
234234
------------------------------

Scripts/new-script.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<#
2+
.SYNOPSIS
3+
new-script.ps1 [<filename>]
4+
.DESCRIPTION
5+
Creates a new PowerShell script.
6+
.EXAMPLE
7+
PS> .\new-script.ps1 myscript.ps1
8+
.NOTES
9+
Author: Markus Fleschutz · License: CC0
10+
.LINK
11+
https://github.com/fleschutz/PowerShell
12+
#>
13+
14+
param([string]$filename = "")
15+
16+
try {
17+
if ($filename -eq "" ) { $shortcut = read-host "Enter the new filename" }
18+
19+
copy-item "$PSScriptRoot/../data/template.ps1" "$filename"
20+
21+
"✔️ created new PowerShell script $filename"
22+
exit 0
23+
} catch {
24+
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
25+
exit 1
26+
}

0 commit comments

Comments
 (0)