PowerShell-Cheat-Sheet

Durchsuchbare Liste wichtiger PowerShell-Cmdlets für Dateien, Prozesse, Dienste, Pipeline und Remoting, für PowerShell 7 und 5.1.

Läuft im Browser · es wird nichts gesendetNeu

44 Befehle

Get-Help <cmdlet> -FullShow the full help page for a cmdlet, including parameters and examples.

Without -Full you get a short summary. Add -Online to open the up-to-date web page instead, or -Examples for just the example section.

Beispiel

Get-Help Get-ChildItem -Examples

Optionen

-OnlineOpen the latest documentation in your browser.
-ExamplesShow only usage examples.
-Parameter <name>Show help for one parameter.
Get-Command *process*Find cmdlets, functions and aliases by (partial) name.

Wildcards work on both sides. Use -Noun or -Verb to search by one part of a Verb-Noun name.

Beispiel

Get-Command -Verb Get -Noun Service

Optionen

-Verb <verb>Only commands with this verb, for example Get, Set, New.
-Noun <noun>Only commands with this noun.
-Module <name>Only commands from one module.
<expression> | Get-MemberList the properties and methods of whatever object(s) came through the pipeline.

Everything in PowerShell is an object, not text, so Get-Member is the main way to discover what you can do with a result before writing the rest of a script.

Beispiel

Get-Process | Get-Member -MemberType Property

Optionen

-MemberType PropertyOnly properties, not methods.
-StaticStatic members of the type instead of the instance.
Update-HelpDownload the latest help files for installed modules.

Help files are not included by default on a fresh install. Run this once (as Administrator) so Get-Help and -Online have real content.

Achtung: Requires internet access and, the first time, an elevated session.
Get-ExecutionPolicy -ListShow the script execution policy for each scope.

Controls whether .ps1 scripts are allowed to run at all. Change it with Set-ExecutionPolicy, most safely at the CurrentUser scope.

Beispiel

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Optionen

RestrictedNo scripts at all (common default on Windows PowerShell 5.1).
RemoteSignedLocal scripts run freely; downloaded scripts need a trusted signature.
BypassNo restriction and no warnings.
Achtung: This is a convenience control, not a security boundary: it only affects double-clicking or running .ps1 files directly, not every way code can execute.
$PROFILEShow the path to your current PowerShell profile script.

A profile script runs automatically at the start of every session, a common place for aliases, functions and module imports. PowerShell 7 and Windows PowerShell 5.1 use separate profile files, so settings do not carry over automatically.

Beispiel

notepad $PROFILE
Get-ChildItem [path]List files and folders. Aliased as ls, dir and gci.

Works on the file system, but also on other PowerShell drives such as the registry (HKLM:\) or environment variables (Env:\).

Beispiel

Get-ChildItem -Recurse -Filter *.log | Select-Object -First 10

Optionen

-RecurseInclude subfolders.
-Filter <pattern>Fast, provider-level wildcard filter.
-FileOnly files.
-DirectoryOnly folders.
-ForceInclude hidden and system items.
Set-Location <path>Change the current directory. Aliased as cd and sl.

Also works on non-filesystem drives, which is how you “cd” into the registry.

Beispiel

Set-Location -Path HKLM:\SOFTWARE
Copy-Item <source> <destination>Copy a file or folder.

Optionen

-RecurseRequired to copy a folder with its contents.
-ForceOverwrite an existing destination and copy read-only or hidden items.
Move-Item <source> <destination>Move or rename a file or folder.

Moving to a new name in the same folder is how you rename something.

Remove-Item <path>Delete a file or folder.

Optionen

-RecurseRequired to delete a non-empty folder.
-ForceDelete hidden, read-only or system items without prompting.
-WhatIfPreview what would be deleted, without deleting it.
Achtung: There is no recycle bin here: Remove-Item deletes permanently. Run with -WhatIf first when the path is built from a variable or wildcard.
New-Item -Path <path> -ItemType <type>Create a new file, folder, or other item.

Beispiel

New-Item -Path .\notes.txt -ItemType File

Optionen

-ItemType DirectoryCreate a folder.
-ItemType FileCreate an empty file.
-Value <text>Initial content for a new file.
Test-Path <path>Check whether a file, folder or registry key exists. Returns True or False.

The usual guard before reading a file or creating one only if it is missing.

Beispiel

if (-not (Test-Path .\out)) { New-Item -ItemType Directory .\out }
Get-Content <path>Read a text file, one line per pipeline object. Aliased as cat, gc and type.

Beispiel

Get-Content .\app.log -Tail 20 -Wait

Optionen

-Tail <n>Only the last n lines.
-WaitKeep the file open and show new lines as they are written, like tail -f.
-RawRead the whole file as one string instead of a line array.
Set-Content <path> -Value <text>Write text to a file, replacing its contents.

Add-Content appends instead of replacing. Out-File is similar but designed to receive pipeline output rather than a -Value string.

Optionen

-Encoding UTF8Set the text encoding explicitly, since the default differs between Windows PowerShell 5.1 (UTF-8 with BOM) and PowerShell 7 (UTF-8 without BOM).
<expression> | Select-Object <properties>Pick specific properties, or the first/last N objects.

Beispiel

Get-Process | Select-Object Name, CPU -First 5

Optionen

-First <n>Only the first n objects.
-Last <n>Only the last n objects.
-ExpandProperty <name>Return the raw values of one property instead of objects.
-UniqueRemove duplicate rows after the selection.
<expression> | Where-Object { <condition> }Filter pipeline objects by a condition. Aliased as where and ?.

$_ refers to the current object. A simplified syntax also works for simple comparisons: Where-Object CPU -gt 10.

Beispiel

Get-Process | Where-Object { $_.CPU -gt 10 }
<expression> | Sort-Object <property>Sort pipeline objects by one or more properties.

Beispiel

Get-ChildItem | Sort-Object Length -Descending

Optionen

-DescendingLargest or last first.
-UniqueRemove duplicates after sorting.
<expression> | ForEach-Object { <script> }Run a script block once per pipeline object. Aliased as % and foreach.

Different from the foreach statement (foreach ($x in $list) {}): ForEach-Object processes one item at a time as it arrives in the pipeline, which uses much less memory for large collections.

Beispiel

Get-ChildItem *.txt | ForEach-Object { Rename-Item $_ ($_.Name + ".bak") }
<expression> | Group-Object <property>Group pipeline objects by a property and count each group.

Beispiel

Get-Process | Group-Object Company | Sort-Object Count -Descending
<expression> | Measure-Object <property>Count objects, or sum/average/min/max a numeric property.

Beispiel

Get-ChildItem *.log | Measure-Object -Property Length -Sum

Optionen

-SumTotal of the property.
-AverageAverage value.
-MaximumLargest value.
-MinimumSmallest value.
<expression> | Format-Table -AutoSizeFormat objects as a table in the console.

Only for display: the output becomes text, so do not pipe it into another cmdlet that expects objects. Format-List shows one property per line instead, better for objects with many properties.

Optionen

-AutoSizeSize columns to fit the content.
-WrapWrap long values instead of truncating them.
<expression> | ConvertTo-JsonSerialize objects to a JSON string.

Beispiel

Get-Process | Select-Object Name, Id | ConvertTo-Json -Depth 3

Optionen

-Depth <n>How many levels of nested objects to include (default 2, often too shallow for complex objects).
<expression> | Export-Csv <path> -NoTypeInformationWrite objects to a CSV file.

-NoTypeInformation drops the #TYPE header line. On PowerShell 7 it is the default and the switch is unnecessary, but harmless to include for scripts shared with Windows PowerShell 5.1.

Beispiel

Get-Process | Export-Csv processes.csv -NoTypeInformation
Get-ProcessList running processes.

Beispiel

Get-Process -Name chrome | Sort-Object CPU -Descending

Optionen

-Name <name>Filter by process name.
-Id <pid>Get one process by its process ID.
Stop-Process -Id <pid>End a running process.

Optionen

-Name <name>Stop by process name instead of ID (stops every matching process).
-ForceStop a process that would otherwise prompt for confirmation.
Achtung: Unsaved work in that process is lost. Prefer closing the application normally when possible.
Get-ServiceList Windows services and their status. Not available on Linux or macOS.

Beispiel

Get-Service -Name wuauserv

Optionen

-Name <name>Filter by service name (wildcards allowed).
-DisplayName <name>Filter by the friendly display name.
Restart-Service -Name <name>Restart a Windows service.

Start-Service and Stop-Service do the same for just starting or stopping. Requires an elevated session for most system services.

Get-WinEvent -LogName System -MaxEvents 50Read entries from a Windows event log.

Get-WinEvent replaces the older Get-EventLog, which only reads classic logs and is not available in PowerShell 7 on non-Windows systems (and is deprecated even on Windows).

Beispiel

Get-WinEvent -FilterHashtable @{ LogName = "Security"; Id = 4625 } -MaxEvents 20

Optionen

-FilterHashtableEfficient server-side filtering by log name, event ID, level or time.
-MaxEvents <n>Limit how many entries are returned.
Restart-ComputerRestart the computer, locally or on a remote one.

Optionen

-ComputerName <name>Restart a remote computer (needs permission and remoting enabled).
-ForceRestart even if users are logged on, without waiting.
Achtung: Closes everything running on that computer. Save work and warn other users on shared or remote machines first.
Get-HotFixList installed Windows updates.

Windows-only. For driver and feature update history, Windows Update's own history view is more complete than Get-HotFix.

$name = <value>Create or update a variable.

Variable names are not case-sensitive. No declaration keyword is needed; the first assignment creates it.

Beispiel

$count = 5
$name = "web-server-01"
"text $variable text"Insert a variable into a string. Only works inside double quotes, not single quotes.

For a property or expression, wrap it: "Count is $($list.Count)". Single-quoted strings are literal and never interpolate.

Beispiel

"Server $name has $count cores"
if (<condition>) { } elseif (<condition>) { } else { }Conditional branching.

Comparison uses operators like -eq, -ne, -gt, -lt, -like and -match, not ==, !=, >, <, which PowerShell parses differently (as redirection in some contexts).

Beispiel

if ($count -gt 10) { "many" } elseif ($count -gt 0) { "some" } else { "none" }
foreach ($item in $collection) { }Loop over a collection, loading it into memory first.

For very large or streamed input, ForEach-Object in a pipeline is usually more memory-efficient.

Beispiel

foreach ($file in Get-ChildItem *.log) { Write-Host $file.Name }
function Verb-Noun { param($x) ... }Define a reusable function.

Community convention is an approved Verb-Noun name (see Get-Verb) so your function behaves like a built-in cmdlet and is easy to discover.

Beispiel

function Get-FileAge {
  param([string]$Path)
  (Get-Date) - (Get-Item $Path).LastWriteTime
}
try { } catch { } finally { }Handle errors that would otherwise stop the script.

Only catches terminating errors. Many cmdlets write non-terminating errors instead; add -ErrorAction Stop to force a cmdlet call to throw one that try/catch can catch.

Beispiel

try {
  Get-Item nonexistent.txt -ErrorAction Stop
} catch {
  Write-Warning $_.Exception.Message
}
-eq -ne -gt -ge -lt -leEquality and comparison operators.

Case-insensitive by default for strings. Prefix with c for case-sensitive (-ceq) or i to be explicit about case-insensitive (-ieq).

Optionen

-eq / -neEqual / not equal.
-gt / -geGreater than / greater than or equal.
-lt / -leLess than / less than or equal.
-like / -notlikeWildcard match with * and ?.
-match / -notmatchRegular expression match.
Get-InstalledModuleList modules installed from the PowerShell Gallery (via PowerShellGet).

Get-Module -ListAvailable shows every module PowerShell can find, including built-in ones; Get-InstalledModule is scoped to what you installed yourself.

Install-Module -Name <name> -Scope CurrentUserDownload and install a module from the PowerShell Gallery.

Optionen

-Scope CurrentUserInstall for your user only, no elevation needed.
-Scope AllUsersInstall machine-wide; needs an elevated session.
-ForceReinstall or install without confirmation prompts.
Achtung: Modules from the Gallery are community-published. Check the publisher and download count before installing something you depend on for production use.
Import-Module <name>Load a module into the current session.

Most modules auto-load the first time one of their commands is used, so this is mainly needed for modules that do not support auto-loading, or to load a specific version.

Invoke-Command -ComputerName <name> -ScriptBlock { }Run a script block on a remote computer over WS-Management (PowerShell Remoting).

Requires PowerShell Remoting to be enabled on the target (Enable-PSRemoting) and, usually, administrative rights there. On the target machine the script runs under Windows PowerShell 5.1 unless the target also has PowerShell 7 remoting configured.

Beispiel

Invoke-Command -ComputerName srv01 -ScriptBlock { Get-Service -Name wuauserv }

Optionen

-Credential <cred>Run as a different user on the remote computer.
-ComputerName <names>One or more target computers, run in parallel.
Enter-PSSession -ComputerName <name>Open an interactive remote session, similar to SSH.

Exit-PSSession or exit returns to the local session. For running the same command on many computers at once, Invoke-Command is usually a better fit than looping Enter-PSSession.

Get-CredentialPrompt for a username and password, returned as a PSCredential object.

Pass the result to a cmdlet's -Credential parameter. The password is stored as a SecureString in memory, not as plain text, but it is still decrypted when the target cmdlet uses it.

Beispiel

$cred = Get-Credential
Invoke-Command -ComputerName srv01 -Credential $cred -ScriptBlock { whoami }

Die Beschreibungen in dieser Referenz sind derzeit auf Englisch.

Erklärung

Suche oder filtere nach Gruppe und kopiere ein Cmdlet mit einem Klick. Öffne ein Cmdlet für Erklärung, Beispiel, wichtigste Parameter und Warnungen, wo es Schaden anrichten kann. Befehle funktionieren sowohl unter Windows PowerShell 5.1 als auch PowerShell 7, sofern nicht anders angegeben.

🔒 Deine Eingabe bleibt in deinem Browser und wird nirgendwohin gesendet.

Häufige Fragen

Sollte ich Windows PowerShell 5.1 oder PowerShell 7 lernen?

Für neue Skripte: PowerShell 7. Es wird aktiv weiterentwickelt und läuft unter Windows, Linux und macOS. Windows PowerShell 5.1 wird weiterhin mit Windows ausgeliefert, und manche Windows-spezifischen Module (wie viele ActiveDirectory-Cmdlets) laden nur dort.

Wie geht es weiter?

Auch nützlich

  • Git-Cheat-SheetDurchsuchbare Liste der nützlichsten Git-Befehle für Setup, Branches, Remotes, Änderungen rückgängig machen und Verlauf ansehen.
  • Linux-Befehle Cheat-SheetDurchsuchbare Liste wichtiger Linux-Befehle für Dateien, Berechtigungen, Text, Prozesse, Dienste, Netzwerk und Benutzer.
  • Windows Event-ID nachschlagenSchlage häufige Windows-Event-IDs nach: Anmeldung, Kontenänderungen, Dienste, Kerberos, RDP und PowerShell. Nützlich für Fehlersuche und Audits.
  • Windows Security Baseline CheckerFüge einen secedit-Export ein, um Passwortrichtlinie, Audit-Einstellungen und Registry-Sicherheitswerte gegen bekannte Baseline-Empfehlungen zu prüfen.

Problem gefunden oder einen Vorschlag? Schreib uns