Powershell

Was ist das? Und warum will ich das nutzen?

Agenda

  1. Historie
  2. Terminal ↔ Shell
  3. Fonts
  4. Profile
  5. Module
  6. Einrichtung

Versionen und Historie

  • 1. Release: November 2006
  • aktuell höchste Version Powershell 7.1.1 (14.01.2021)
  • Auf Windows 10 vorinstallierte Version: 5.1

Unterstützte Systeme

Windows Logo

Unterstützte Systeme

Windows Logo
seit Powershell 6:
Linux Logo Apple Logo

Terminal ↔ Shell

Terminal ist das Programm in dem die Shell angezeigt wird.

klassisches Terminal

Terminal klassisch

PowerShell ISE

Terminal ISE

ConEmu

Terminal ConEmu
LINK

Terminal App

LINK + DOKU

Dropdown-/Quake-Terminal (ConEmu)


Meine Einstellungen stelle ich auf Anfrage gern bereit.

Dropdown-/Quake-Terminal (Windows Terminal)

Fonts

Hack Nerd Font

Profile

  • wird beim Start ausgeführt
  • unterschiedliche Orte für
    • Windows Powershell
    • Powershell
    • Powershell ISE

Profilpfad für Environment bestimmen:

							echo $PROFILE
						

Beispiel - Profil


							New-Alias -Name g -Value git
							function cgit { set-location "d:\git" }

							Set-PSReadlineKeyHandler -Key Tab -Function Complete

							Clear-Host
						

Beispiel - Methode


							function RDP {
							<#
							.SYNOPSIS
								Wrapper fuer mstsc
							.PARAMETER HostName
								Der Host auf welchen verbunden werden soll.
							.EXAMPLE
								RDP srvbeispiel
							.EXAMPLE
								RDP -HostName srvbeispiel
							#>
								param (
									[parameter (Mandatory=$true)]
									[string]$RDPHost
								)

								mstsc /v:${RDPHost} /prompt
							}
						

Mein Profil

Mein Profil habe ich auf Github hinterlegt:
github.com/Kikkirej/scripts

Mit einem Symlink lässt sich die Datei dann an die anderen Orte legen.

							New-Item
							  -Path C:\Users\username\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
							  -ItemType SymbolicLink
							  -Value C:\scripts\Microsoft.PowerShell_profile.ps1
						

Module

Installation

Möglichkeit zu Installation von Modulen direkt in der Powershell.
(auch mit Proxy kein Problem)

							Install-Module posh-git -Scope CurrentUser
						

Powershell Gallery

www.powershellgallery.com
Achtung: hier nicht blind vertrauen.

Laden von Modulen

Damit die Module zur Laufzeit verfügbar sind müssen diese geladen werden.
→ Profil


							Import-Module posh-git
						

Empfohlene Module

  • posh-git - Git Autovervollständigung
  • Terminal-Icons
  • posh-docker - Docker Autovervollständigung

Starship

LINK

Einrichtung