Add edit.ps1 and introduce-powershell.ps1

This commit is contained in:
Markus Fleschutz 2021-03-29 19:26:42 +02:00
parent b4ba271ff2
commit 4a4c074c83
4 changed files with 54 additions and 1 deletions

View File

@ -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

1 Script Description
32 decrypt-file.ps1 decrypts the given file
33 display-time.ps1 displays the current time for 10 seconds by default
34 download.ps1 downloads the file/directory from the given URL
35 edit.ps1 edits the given file with the built-in text editor
36 enable-crash-dumps.ps1 enables the writing of crash dumps
37 enable-god-mode.ps1 enables the god mode (adds a new icon to the desktop)
38 enable-ssh-client.ps1 enables the SSH client
48 go-scripts.ps1 go to the PowerShell Scripts folder
49 hibernate.ps1 enables hibernate mode for the local computer (requires admin rights)
50 inspect-exe.ps1 prints basic information of the given executable file
51 introduce-powershell.ps1 introduces PowerShell to new users
52 list-aliases.ps1 lists all PowerShell aliases
53 list-anagrams.ps1 lists all anagrams of the given word
54 list-automatic-variables.ps1 lists the automatic variables of PowerShell

View File

@ -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

19
Scripts/edit.ps1 Normal file
View File

@ -0,0 +1,19 @@
#!/bin/powershell
<#
.SYNTAX ./edit.ps1 <filename>
.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
}

View File

@ -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
}