PowerShell/README.md

78 lines
3.7 KiB
Markdown
Raw Normal View History

2020-06-19 18:00:03 +02:00
Collection of Useful PowerShell Scripts (CUPS)
==============================================
2020-05-01 11:44:56 +02:00
2020-04-30 17:59:12 +02:00
Useful cross-platform PowerShell scripts, to be used on the command-line (CLI) or by automation software like Jenkins.
2020-05-01 11:44:56 +02:00
2020-09-25 14:50:28 +02:00
PowerShell Scripts Included
---------------------------
2020-09-25 14:54:33 +02:00
* [exe_info.ps1](Scripts/exe_info.ps1) - prints basic information of the given executable file
2020-09-25 14:47:09 +02:00
* **lscmdlets.ps1** - lists all PowerShell cmdlets
* **lsmods.ps1** - lists all PowerShell modules
* **lsproc.ps1** - lists the local computer processes
2020-06-15 16:40:40 +02:00
* **MD5.ps1** - prints the MD5 checksum of the given file
2020-06-23 18:56:04 +02:00
* **moon.ps1** - prints the current moon phase
2020-05-25 17:48:09 +02:00
* **password.ps1** - generates and prints a single new password
* **passwords.ps1** - generates and prints a list of new passwords
* **poweroff.ps1** - halts the local computer, administrator rights might be needed
2020-06-19 17:53:02 +02:00
* **news.ps1** - print the latest news
2020-05-25 17:48:09 +02:00
* **reboot.ps1** - reboots the local computer, administrator rights might be needed
2020-06-15 16:40:40 +02:00
* **SHA1.ps1** - prints the SHA1 checksum of the given file
* **SHA256.ps1** - prints the SHA256 checksum of the given file
2020-05-25 17:48:09 +02:00
* **speak.ps1** - speaks the given text
2020-06-15 14:50:53 +02:00
* **test.ps1** - simple test script
2020-06-15 16:40:40 +02:00
* **train_dns_cache.ps1** - trains the DNS cache with frequently used domain names
2020-05-25 17:48:09 +02:00
* **translate.ps1** - translates the given text
* **txt2wav.ps1** - converts text into a audio .WAV file
2020-06-23 18:56:04 +02:00
* **weather.ps1** - prints the current weather forecast
2020-05-25 17:48:09 +02:00
* **wakeup.ps1** - sends a magic packet to the given computer, waking him up
2020-06-23 20:34:12 +02:00
* **zipdir.ps1** - creates a zip archive of the given folder
2020-05-22 09:54:16 +02:00
2020-08-11 13:48:27 +02:00
What is PowerShell?
-------------------
2020-06-15 16:01:12 +02:00
2020-05-04 14:39:06 +02:00
PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language.
2020-08-11 14:15:02 +02:00
* it's **cross-platform**: available for Linux, Mac OS and Windows
2020-08-11 13:51:30 +02:00
* it's **powerful**: fully control your computer
* it's **open-source**: see the Github repository at https://github.com/PowerShell/PowerShell
* it's **easy to learn**: see the tutorial at https://www.guru99.com/powershell-tutorial.html
* it's **fully documented**: see the official docs at https://docs.microsoft.com/en-us/powershell/
2020-05-01 11:44:56 +02:00
2020-08-11 13:48:27 +02:00
How to get PowerShell?
----------------------
2020-08-11 14:11:48 +02:00
Windows 7 and newer do provide PowerShell by default. It's recommended to use it via **Windows Terminal** (see the Microsoft Store at https://www.aka.ms/terminal).
For installation on alternative platforms (CentOS, Debian, Docker, Fedora, macOS, openSUSE, Red Hat, Ubuntu) visit https://github.com/PowerShell/PowerShell.
2020-08-11 13:48:27 +02:00
2020-08-11 14:29:29 +02:00
Afterward, install the scripts by clicking on the green "Code" button or execute:
2020-08-11 14:27:11 +02:00
```
$ git clone https://github.com/fleschutz/PowerShell
```
2020-08-11 13:48:27 +02:00
How to configure PowerShell as default shell on Linux?
------------------------------------------------------
2020-06-15 16:01:12 +02:00
2020-06-15 16:42:52 +02:00
Make sure PowerShell is installed, then use the `chsh` commmand as follows:
* `chsh -s /bin/powershell <username>`
2020-06-15 15:56:18 +02:00
2020-08-11 14:11:48 +02:00
2020-08-11 13:48:27 +02:00
How to add the subfolder Scripts/ to the search path for command-line usage?
----------------------------------------------------------------------------
2020-06-15 16:01:12 +02:00
2020-05-25 20:55:16 +02:00
* **Windows:** open the environment variables dialogue and add the full path to Scripts/ to the system environment variable "Path"
* **Bash or sh:** edit .profile in your home directory and add the line: PATH="$PATH:/path/to/PowerShell/Scripts"
2020-05-25 20:37:47 +02:00
2020-05-01 12:09:03 +02:00
Script Standards
----------------
Each script provides:
2020-06-15 16:42:52 +02:00
1. a comment header containing the syntax, description, author, source, and license
2020-06-15 16:01:12 +02:00
2. prefers command-line options but may ask the user in case no option is given
2020-05-04 14:27:48 +02:00
3. exits 0 for success, otherwise the error code (mostly 1)
2020-05-02 13:01:03 +02:00
2020-06-15 15:09:54 +02:00
Feedback
--------
2020-06-15 16:01:12 +02:00
Send your email feedback to: markus [at] fleschutz [dot] de
2020-06-15 15:09:54 +02:00
2020-05-02 13:01:03 +02:00
License & Copyright
-------------------
This open source release is licensed under the CC0 license. All trademarks are the property of their respective owners.