From ec9253f38ad964ce236d90b4ea650e7bc4f3fe41 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 30 Aug 2021 12:21:01 +0200 Subject: [PATCH] Add new-script.ps1 --- Data/scripts.csv | 2 +- {Scripts => Data}/template.ps1 | 0 README.md | 2 +- Scripts/new-script.ps1 | 26 ++++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) rename {Scripts => Data}/template.ps1 (100%) create mode 100755 Scripts/new-script.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index 9ec37068..9b9bba21 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -177,6 +177,7 @@ pull-repo.ps1, pulls updates for the current/given Git repository (including sub pull-repos.ps1, pulls updates for all Git repositories under the current/given directory (including submodules) 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 new-email.ps1, starts the default email client to write a new email +new-script.ps1, creates a new PowerShell script reboot.ps1, reboots the local computer (needs admin rights) reboot-fritzbox.ps1, reboots the FRITZ!box device 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 sync-repo.ps1, synchronizes a Git repository by push & pull (including submodules) take-screenshot.ps1, takes a single screenshot take-screenshots.ps1, takes multiple screenshots -template.ps1, copy this template PowerShell script to write a new one translate-file.ps1, translates the given text file into another language translate-files.ps1, translates the given text files into any supported language translate-text.ps1, translates the given text into other languages diff --git a/Scripts/template.ps1 b/Data/template.ps1 similarity index 100% rename from Scripts/template.ps1 rename to Data/template.ps1 diff --git a/README.md b/README.md index 28329d0e..dc9cabb0 100644 --- a/README.md +++ b/README.md @@ -227,8 +227,8 @@ Mega Collection of PowerShell Scripts | [list-modules.ps1](Scripts/list-modules.ps1) | Lists the PowerShell modules | [Manual](Docs/list-modules.ps1.md) | | [list-profiles.ps1](Scripts/list-profiles.ps1) | Lists your PowerShell profiles | [Manual](Docs/list-profiles.ps1.md) | | [list-scripts.ps1](Scripts/list-scripts.ps1) | Lists all PowerShell scripts in this repository | [Manual](Docs/list-scripts.ps1.md) | +| [new-script.ps1](Scripts/new-script.ps1) | Creates a new PowerShell script | [Manual](Docs/new-script.ps1.md) | | [set-profile.ps1](Scripts/set-profile.ps1) | Updates your PowerShell user profile | [Manual](Docs/set-profile.ps1.md) | -| [template.ps1](Scripts/template.ps1) | Copy this template PowerShell script to write a new one | [Manual](Docs/template.ps1.md) | 🛒 Various PowerShell Scripts ------------------------------ diff --git a/Scripts/new-script.ps1 b/Scripts/new-script.ps1 new file mode 100755 index 00000000..6f15dc38 --- /dev/null +++ b/Scripts/new-script.ps1 @@ -0,0 +1,26 @@ +<# +.SYNOPSIS + new-script.ps1 [] +.DESCRIPTION + Creates a new PowerShell script. +.EXAMPLE + PS> .\new-script.ps1 myscript.ps1 +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +param([string]$filename = "") + +try { + if ($filename -eq "" ) { $shortcut = read-host "Enter the new filename" } + + copy-item "$PSScriptRoot/../data/template.ps1" "$filename" + + "✔️ created new PowerShell script $filename" + exit 0 +} catch { + write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}