{"id":2245,"date":"2022-09-14T10:16:59","date_gmt":"2022-09-14T08:16:59","guid":{"rendered":"https:\/\/davidka.net\/en\/?p=2245"},"modified":"2025-09-20T19:06:04","modified_gmt":"2025-09-20T17:06:04","slug":"%e2%9a%a1-powershell-cheat-sheet-advanced","status":"publish","type":"post","link":"https:\/\/de.davidka.net\/de\/2022\/09\/14\/%e2%9a%a1-powershell-cheat-sheet-advanced\/","title":{"rendered":"\u26a1 PowerShell-Spickzettel \u2014 Fortgeschritten"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\ud83d\udd39 Remote-Verwaltung<\/h1>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">Enter-PSSession -ComputerName<\/code><\/td><td>Remote-Sitzung starten<\/td><td><code class=\"\" data-line=\"\">Enter-PSSession -ComputerName Server01<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Invoke-Command -ComputerName<\/code><\/td><td>Befehl remote ausf\u00fchren<\/td><td><code class=\"\" data-line=\"\">Invoke-Command -ComputerName Server01 -ScriptBlock { Get-Process }<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Fehlerbehandlung<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">try { ... } catch { ... }<\/code><\/td><td>Fehlerbehandlung<\/td><td><code class=\"\" data-line=\"\">try { Get-Item &quot;nonexistent.txt&quot; } catch { Write-Output &quot;Error: $_&quot; }<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Regul\u00e4re Ausdr\u00fccke<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">-match<\/code><\/td><td>Pr\u00fcfung auf \u00dcbereinstimmung<\/td><td><code class=\"\" data-line=\"\">&quot;Hello123&quot; -match &quot;\\d+&quot;<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">-replace<\/code><\/td><td>Ersetzen von Zeichen<\/td><td><code class=\"\" data-line=\"\">&quot;abc123&quot; -replace &quot;\\d+&quot;, &quot;&quot;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 JSON und XML<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">ConvertFrom-Json<\/code> \/ <code class=\"\" data-line=\"\">ConvertTo-Json<\/code><\/td><td>JSON lesen und schreiben<\/td><td>`$json = Get-Content file.json<\/td><\/tr><tr><td><code class=\"\" data-line=\"\">[xml]<\/code><\/td><td>XML einlesen<\/td><td><code class=\"\" data-line=\"\">[xml]$xml = Get-Content file.xml<\/code><code class=\"\" data-line=\"\">$xml.DocumentElement.ElementName<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Hintergrundjobs<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">Start-Job<\/code><\/td><td>Job im Hintergrund starten<\/td><td><code class=\"\" data-line=\"\">Start-Job -ScriptBlock { Get-Process }<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Get-Job<\/code><\/td><td>Aktive Jobs anzeigen<\/td><td><code class=\"\" data-line=\"\">Get-Job<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Receive-Job<\/code><\/td><td>Ergebnisse eines Jobs abrufen<\/td><td><code class=\"\" data-line=\"\">Receive-Job -Id 1<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Remove-Job<\/code><\/td><td>Job l\u00f6schen<\/td><td><code class=\"\" data-line=\"\">Remove-Job -Id 1<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Geplante Aufgaben<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">Register-ScheduledTask<\/code><\/td><td>Geplante Aufgabe erstellen<\/td><td><code class=\"\" data-line=\"\">Register-ScheduledTask -Action (New-ScheduledTaskAction -Execute &quot;notepad.exe&quot;) -Trigger (New-ScheduledTaskTrigger -At 12pm -Daily) -TaskName &quot;NotepadTask&quot;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Sicherheit und Anmeldedaten<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">Get-Credential<\/code><\/td><td>Anmeldedaten abfragen<\/td><td><code class=\"\" data-line=\"\">Get-Credential<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Invoke-Command<\/code><\/td><td>Remote-Befehl mit Anmeldedaten<\/td><td><code class=\"\" data-line=\"\">Invoke-Command -ComputerName Server01 -Credential (Get-Credential) -ScriptBlock { Get-Service }<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Leistung und Protokollierung<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Befehl<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr><\/thead><tbody><tr><td><code class=\"\" data-line=\"\">Measure-Command<\/code><\/td><td>Ausf\u00fchrungszeit messen<\/td><td><code class=\"\" data-line=\"\">Measure-Command { Get-Process }<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Start-Transcript<\/code><\/td><td>Sitzung protokollieren<\/td><td><code class=\"\" data-line=\"\">Start-Transcript -Path log.txt<\/code><\/td><\/tr><tr><td><code class=\"\" data-line=\"\">Stop-Transcript<\/code><\/td><td>Protokollierung beenden<\/td><td><code class=\"\" data-line=\"\">Stop-Transcript<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udd39 Remote-Verwaltung Befehl Beschreibung Beispiel Enter-PSSession -ComputerName Remote-Sitzung starten Enter-PSSession -ComputerName Server01 Invoke-Command -ComputerName Befehl remote ausf\u00fchren Invoke-Command -ComputerName Server01 -ScriptBlock { Get-Process } \ud83d\udd39 Fehlerbehandlung Befehl Beschreibung Beispiel try { &#8230; } catch { &#8230; } Fehlerbehandlung try { Get-Item &quot;nonexistent.txt&quot; } catch { Write-Output &quot;Error: $_&quot; } \ud83d\udd39 Regul\u00e4re Ausdr\u00fccke Befehl Beschreibung Beispiel&hellip;&nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-2245","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/posts\/2245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/comments?post=2245"}],"version-history":[{"count":0,"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/posts\/2245\/revisions"}],"wp:attachment":[{"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/media?parent=2245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/categories?post=2245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/de.davidka.net\/de\/wp-json\/wp\/v2\/tags?post=2245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}