{"id":1439,"date":"2026-08-03T07:30:31","date_gmt":"2026-08-03T07:30:31","guid":{"rendered":"https:\/\/blog.faktor0.de\/?p=1439"},"modified":"2026-08-10T10:06:28","modified_gmt":"2026-08-10T10:06:28","slug":"powershell-tips-tricks","status":"publish","type":"post","link":"https:\/\/blog.faktor0.de\/?p=1439","title":{"rendered":"Powershell Tips &#038; Tricks"},"content":{"rendered":"<p><strong>Firefox herunterladen:<\/strong><br \/>\n<code>Invoke-WebRequest -Uri \"https:\/\/download.mozilla.org\/?product=firefox-latest-ssl&os=win64&lang=de\" -OutFile \"firefox_installer.exe\"<\/code><\/p>\n<p><strong>Windows-Programm ausf\u00fchren und Returncode anzeigen:<\/strong><br \/>\n<code>$process = Start-Process notepad.exe -ArgumentList \"C:\\path\\to\\file.txt\" -Wait -PassThru<\/p>\n<p># Retrieve the return code<br \/>\n$process.ExitCode<\/code><\/p>\n<p><strong>Nach Werten in der Registry suchen:<\/strong><\/p>\n<p><code>function Search-Registry {<br \/>\n    [CmdletBinding()]<br \/>\n    param(<br \/>\n        [Parameter(Mandatory = $true)]<br \/>\n        [string]$SearchTerm,<\/p>\n<p>        [Parameter(Mandatory = $false)]<br \/>\n        [string]$Path = 'HKLM:\\SOFTWARE'<br \/>\n    )<\/p>\n<p>    Get-ChildItem -Path $Path -Recurse -ErrorAction SilentlyContinue | ForEach-Object {<br \/>\n        $key = $_<\/p>\n<p>        # 1. Match Key Name<br \/>\n        if ($key.Name -match [regex]::Escape($SearchTerm)) {<br \/>\n            [PSCustomObject]@{<br \/>\n                Type  = 'Key Name'<br \/>\n                Path  = $key.Name<br \/>\n                Name  = ''<br \/>\n                Value = ''<br \/>\n            }<br \/>\n        }<\/p>\n<p>        # 2. Match Property Names and Values<br \/>\n        try {<br \/>\n            $key.GetValueNames() | ForEach-Object {<br \/>\n                $valueName = $_<br \/>\n                $valueData = $key.GetValue($valueName)<\/p>\n<p>                if ($valueName -match [regex]::Escape($SearchTerm) -or $valueData -match [regex]::Escape($SearchTerm)) {<br \/>\n                    [PSCustomObject]@{<br \/>\n                        Type  = 'Value \/ Data'<br \/>\n                        Path  = $key.Name<br \/>\n                        Name  = $valueName<br \/>\n                        Value = $valueData<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n        } catch {<br \/>\n            # Skip keys that cannot be read due to permissions<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>if ($args.Count -eq 1) {<br \/>\n    Search-Registry -SearchTerm $args[0] -Path \"HKLM:\\SOFTWARE\"<br \/>\n}<br \/>\nelse {<br \/>\n    \"Usage: SearchReg <term>\"<br \/>\n}<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Firefox herunterladen: Invoke-WebRequest -Uri &#8222;https:\/\/download.mozilla.org\/?product=firefox-latest-ssl&#038;os=win64&#038;lang=de&#8220; -OutFile &#8222;firefox_installer.exe&#8220; Windows-Programm ausf\u00fchren und Returncode anzeigen: $process = Start-Process notepad.exe -ArgumentList &#8222;C:\\path\\to\\file.txt&#8220; -Wait -PassThru # Retrieve the return code $process.ExitCode Nach Werten in der Registry suchen: function Search-Registry { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$SearchTerm, [Parameter(Mandatory = $false)] [string]$Path = &#8218;HKLM:\\SOFTWARE&#8216; ) Get-ChildItem -Path $Path -Recurse -ErrorAction SilentlyContinue | [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,24],"tags":[],"class_list":["post-1439","post","type-post","status-publish","format-standard","hentry","category-powershell","category-windows"],"_links":{"self":[{"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=\/wp\/v2\/posts\/1439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1439"}],"version-history":[{"count":6,"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=\/wp\/v2\/posts\/1439\/revisions"}],"predecessor-version":[{"id":1447,"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=\/wp\/v2\/posts\/1439\/revisions\/1447"}],"wp:attachment":[{"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.faktor0.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}