PowerShell/README.md
2020-11-01 11:20:55 +00:00

5.4 KiB

Collection of Useful PowerShell Scripts (CUPS)

Useful cross-platform PowerShell scripts, to be used on the command-line (CLI) or by automation software like 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?

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.

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

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

How to configure PowerShell as default shell on Linux?

Make sure PowerShell is installed, then use the chsh commmand as follows:

  • chsh -s /bin/powershell <username>

How to add the subfolder Scripts/ to the search path for command-line usage?

  • 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"

Script Standards

Each script should support the following rules:

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