From 4a4c074c83f65fb7844ea81f596fc4ec24f2f9d7 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 29 Mar 2021 19:26:42 +0200 Subject: [PATCH] Add edit.ps1 and introduce-powershell.ps1 --- Data/scripts.csv | 2 ++ README.md | 4 +++- Scripts/edit.ps1 | 19 +++++++++++++++++++ Scripts/introduce-powershell.ps1 | 30 ++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 Scripts/edit.ps1 create mode 100644 Scripts/introduce-powershell.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index 2ea2b866..ec11d793 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -32,6 +32,7 @@ daily-tasks.sh, execute PowerShell scripts automatically as daily tasks (Linux o decrypt-file.ps1, decrypts the given file display-time.ps1, displays the current time for 10 seconds by default download.ps1, downloads the file/directory from the given URL +edit.ps1, edits the given file with the built-in text editor enable-crash-dumps.ps1, enables the writing of crash dumps enable-god-mode.ps1, enables the god mode (adds a new icon to the desktop) enable-ssh-client.ps1, enables the SSH client @@ -47,6 +48,7 @@ go-root.ps1, go to the root directory (C: on Windows) go-scripts.ps1, go to the PowerShell Scripts folder hibernate.ps1, enables hibernate mode for the local computer (requires admin rights) inspect-exe.ps1, prints basic information of the given executable file +introduce-powershell.ps1, introduces PowerShell to new users list-aliases.ps1, lists all PowerShell aliases list-anagrams.ps1, lists all anagrams of the given word list-automatic-variables.ps1, lists the automatic variables of PowerShell diff --git a/README.md b/README.md index dd798370..3d3722ee 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ Mega Collection of PowerShell Scripts * [create-shortcut.ps1](Scripts/create-shortcut.ps1) - creates a shortcut * [create-symlink.ps1](Scripts/create-symlink.ps1) - creates a symbolic link * [decrypt-file.ps1](Scripts/decrypt-file.ps1) - encrypts the given file +* [download.ps1](Scripts/download.ps1) - downloads the file/directory from the given URL +* [edit.ps1](Scripts/edit.ps1) - edits the given file with the built-in text editor * [encrypt-file.ps1](Scripts/encrypt-file.ps1) - encrypts the given file * [go-downloads.ps1](Scripts/go-downloads.ps1) - go to the user's downloads folder * [go-home.ps1](Scripts/go-home.ps1) - go to the user's home folder @@ -124,6 +126,7 @@ Mega Collection of PowerShell Scripts 🔎 Scripts for PowerShell ------------------------ * [daily-tasks.sh](Scripts/daily-tasks.sh) - execute PowerShell scripts automatically as daily tasks (Linux only) +* [introduce-powershell.sh](Scripts/introduce-powershell.sh) - introduces PowerShell to new users * [list-aliases.ps1](Scripts/list-aliases.ps1) - lists all PowerShell aliases * [list-automatic-variables.ps1](Scripts/list-automatic-variables.ps1) - lists the automatic variables of PowerShell * [list-cmdlets.ps1](Scripts/list-cmdlets.ps1) - lists the PowerShell cmdlets @@ -139,7 +142,6 @@ Mega Collection of PowerShell Scripts * [check-mac-address.ps1](Scripts/check-mac-address.ps1) - checks the given MAC address for validity * [csv-to-text.ps1](Scripts/csv-to-text.ps1) - converts the given CSV file into a text list * [display-time.ps1](Scripts/display-time.ps1) - displays the current time for 10 seconds by default -* [download.ps1](Scripts/download.ps1) - downloads the file/directory from the given URL * [generate-qrcode.ps1](Scripts/generate-qrcode.ps1) - generates a QR code * [list-anagrams.ps1](Scripts/list-anagrams.ps1) - lists all anagrams of the given word * [list-environment-variables.ps1](Scripts/list-environment-variables.ps1) - lists all environment variables diff --git a/Scripts/edit.ps1 b/Scripts/edit.ps1 new file mode 100644 index 00000000..0b39b6ad --- /dev/null +++ b/Scripts/edit.ps1 @@ -0,0 +1,19 @@ +#!/bin/powershell +<# +.SYNTAX ./edit.ps1 +.DESCRIPTION starts the built-in text editor to edit the given file +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +param($Filename = "") + +try { + & notepad.exe "$Filename" + if ($lastExitCode -ne "0") { throw "Can't execute 'notepad.exet' - make sure notepad.exe is installed and available" } + + exit 0 +} catch { + write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} diff --git a/Scripts/introduce-powershell.ps1 b/Scripts/introduce-powershell.ps1 new file mode 100644 index 00000000..93f8f30d --- /dev/null +++ b/Scripts/introduce-powershell.ps1 @@ -0,0 +1,30 @@ +#!/bin/powershell +<# +.SYNTAX ./introduce-powershell.ps1 +.DESCRIPTION introduces PowerShell to new users +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +try { + & write-big.ps1 "PowerShell" + + & write-animated.ps1 "Welcome to PowerShell" + & write-animated.ps1 "Feel the power of the console and scripting" + + "" + "* Want to learn PowerShell? See the tutorials at: https://www.guru99.com/powershell-tutorial.html" + "" + "* Need documentation? See the PowerShell docs at: https://docs.microsoft.com/en-us/powershell/" + "" + "* Want sample scripts? See PowerShell Scripts at: https://github.com/fleschutz/PowerShell/" + "" + + & write-typewriter.ps1 "P.S. PowerShell is looking forward to execute your next command" + "" + + exit 0 +} catch { + write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}