500+ PowerShell scripts (.ps1) for every system!
Go to file
2020-12-09 09:22:41 +00:00
Context_Menus Added folder Context_Menus/ 2020-12-08 13:00:56 +00:00
Scripts Added send-tcp.ps1 2020-12-09 09:22:41 +00:00
LICENSE Initial commit 2020-04-30 17:49:27 +02:00
README.md Added send-tcp.ps1 2020-12-09 09:22:41 +00:00

Collection of Useful PowerShell Scripts (CUPS)

This repository contains 40+ useful cross-platform PowerShell scripts - to be used on the command-line (CLI), by context menu, by voice control, or by automation software (e.g. Jenkins).

List of Scripts

The following PowerShell scripts can be found in the Scripts/ subfolder:

What is PowerShell?

PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language.

How to get PowerShell?

Afterward, install CUPS by clicking on the green "Code" button or execute:

$ git clone https://github.com/fleschutz/PowerShell

Configure PowerShell as Default Shell

  • Linux: make sure PowerShell is installed, then execute: chsh -s /snap/bin/powershell <username>
  • Windows: no need to, PowerShell is the default shell

Adding Subfolder Scripts/ to the Search Path for Command-line Usage

  • Bash or sh: edit .profile in your home directory and add the line: PATH="$PATH:/path/to/PowerShell/Scripts"
  • Windows: open the environment variables dialogue and add the full path to Scripts/ to the system environment variable "Path"

Using PowerShell in Windows Context Menus

  • to enable "right-click > New > Windows PowerShell Script" just execute Context_Menus/add_ps1_to_New_context_menu.reg
  • to disable it just execute Context_Menus/remove_ps1_from_New_context_menu.reg

Script Conventions

Each PowerShell script should follow the 7 golden rules:

  • Rule 1: the filename should be named <verb>-<object>.ps1
  • Rule 2: to support PowerShell on Linux the first line reads: #!/snap/bin/powershell
  • Rule 3: to support PowerShell on Linux the script has execute file permissions (chmod a+rx )
  • Rule 4: add a metadata header containing the syntax, description, author, source, and license
  • Rule 5: prefer command-line options, but may ask the user in case no option is given
  • Rule 6: the encoding of the script is in UTF-8 with BOM to support Unicode characters
  • Rule 7: exit 0 for success, else print an error message and exit with the error code (mostly 1)

Feedback

Send your email feedback to: markus [at] fleschutz [dot] de

This open source release is licensed under the CC0 license. All trademarks are the property of their respective owners.