{"id":208568,"date":"2024-01-24T13:36:04","date_gmt":"2024-01-24T13:36:04","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/anleitung-zum-deaktivieren-der-powershell-2\/"},"modified":"2024-03-04T17:50:41","modified_gmt":"2024-03-04T17:50:41","slug":"anleitung-zum-deaktivieren-der-powershell-2","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/anleitung-zum-deaktivieren-der-powershell-2\/","title":{"rendered":"So deaktivieren Sie PowerShell 2.0: Leitfaden mit Skript"},"content":{"rendered":"<p>Hallo, Technik-Profis! Wenn Sie ein IT-Administrator sind oder im Bereich Managed Services (MSP) arbeiten, wissen Sie, dass die Sicherheit Ihrer Umgebung an erster Stelle steht. Ein Bereich, der h\u00e4ufig \u00fcberpr\u00fcft werden muss, ist die Konfiguration von PowerShell auf Ihren Windows-Systemen. Lassen Sie uns also \u00fcber <strong>PowerShell 2.0<\/strong>sprechen und dar\u00fcber, warum Sie es m\u00f6glicherweise deaktivieren m\u00f6chten. Besser noch: Lassen Sie uns \u00fcber ein Skript sprechen, das diese Aufgabe f\u00fcr Sie \u00fcbernimmt.<\/p>\n<h2>Warum PowerShell 2.0 deaktivieren?<\/h2>\n<p>Zun\u00e4chst einmal sollten Sie verstehen, warum Sie PowerShell 2.0 deaktivieren. In dieser veralteten Version von PowerShell fehlen zahlreiche Sicherheitsfunktionen und Verbesserungen, die in aktuelleren Versionen vorhanden sind. Das ist praktisch eine offene Einladung an b\u00f6swillige Akteure, Ihre Systeme auszunutzen.<\/p>\n<h2>Das PowerShell 2.0-Skript Deaktivieren<\/h2>\n<p>Nachdem wir nun das &#8222;Warum&#8220; gekl\u00e4rt haben, lassen Sie uns \u00fcber das &#8222;Wie&#8220; sprechen Das Skript zum Deaktivieren von PowerShell 2.0 ist Ihre All-in-One-L\u00f6sung. In PowerShell 5.1 verfasst, ist das Skript darauf ausgelegt, auf Windows 10, Windows Server 2016 und neuer zu funktionieren.<\/p>\n<h3><strong>Das bietet dieses Skript:<\/strong><\/h3>\n<h4><em>Pr\u00fcfung auf erh\u00f6hte Rechte<\/em><\/h4>\n<p>Das Skript pr\u00fcft zun\u00e4chst, ob es mit Administratorrechten ausgef\u00fchrt wird, und wenn nicht, werden Sie darauf hingewiesen, dass es als Administrator ausgef\u00fchrt werden muss.<\/p>\n<h4><em>OS und Versionskontrolle<\/em><\/h4>\n<p>Bevor es versucht, PowerShell 2.0 zu entfernen, \u00fcberpr\u00fcft es Ihre PowerShell-Version. Sie m\u00fcssen PowerShell 5.1 oder h\u00f6her ausf\u00fchren. Das ist eine gute Funktion, die sicherstellt, dass Sie Ihre bestehende Einrichtung nicht durcheinander bringen.<\/p>\n<h4><em>Die Entfernung<\/em><\/h4>\n<p>Das Skript verwendet verschiedene Befehle<em>(Disable-WindowsOptionalFeature und Uninstall-WindowsFeature<\/em>) , die auf Ihrem Betriebssystem basieren, um PowerShell 2.0 zu deaktivieren. Wenn PowerShell 2.0 bereits deaktiviert ist, werden Sie dar\u00fcber informiert.<\/p>\n<h2>Das Skript<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Disables PowerShell 2.0.\r\n.DESCRIPTION\r\n    Disables PowerShell 2.0 by removing the feature.\r\n    This script does require that PowerShell 5.1 be installed before hand.\r\n    See: https:\/\/docs.microsoft.com\/en-us\/powershell\/scripting\/windows-powershell\/wmf\/setup\/install-configure\r\n.EXAMPLE\r\n    No parameters needed.\r\n.OUTPUTS\r\n    String[]\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes:\r\n    Initial Release\r\n    (c) 2023 NinjaOne\r\n    By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam ()\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    if ($PSVersionTable.PSVersion -ge [Version]::new(5, 1)) {\r\n        if ($(Get-Command \"Disable-WindowsOptionalFeature\" -ErrorAction SilentlyContinue).Name -like \"Disable-WindowsOptionalFeature\") {\r\n            if ($(Get-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2 -ErrorAction SilentlyContinue).State -like \"Enabled\") {\r\n                # Remove PowerShell 2.0 on Windows 10,11\r\n                try {\r\n                    Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2 -ErrorAction Stop\r\n                    Write-Host \"Disabled PowerShell 2.0\"\r\n                }\r\n                catch {\r\n                    Write-Error $_\r\n                    Write-Host \"Unable to disable PowerShell 2.0\"\r\n                    exit 1\r\n                }\r\n            }\r\n            if ($(Get-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root -ErrorAction SilentlyContinue).State -like \"Enabled\") {\r\n                # Remove PowerShell 2.0 on Windows 10, 11, Server 2016\r\n                try {\r\n                    Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root -ErrorAction Stop\r\n                    Write-Host \"Disabled PowerShell 2.0\"\r\n                }\r\n                catch {\r\n                    Write-Error $_\r\n                    Write-Host \"Unable to disable PowerShell 2.0\"\r\n                    exit 1\r\n                }\r\n            }\r\n            else {\r\n                Write-Host \"PowerShell is already disabled.\"\r\n            }\r\n        }\r\n        if ($(Get-Command \"Uninstall-WindowsFeature\" -ErrorAction SilentlyContinue).Name -like \"Uninstall-WindowsFeature\") {\r\n            if ($(Get-WindowsFeature -Name PowerShell-V2) -and $(Get-WindowsFeature -Name PowerShell-V2).InstallState -like \"Installed\") {\r\n                # Remove PowerShell 2.0 on Windows Server\r\n                try {\r\n                    Uninstall-WindowsFeature -Name PowerShell-V2 -ErrorAction Stop\r\n                    Write-Host \"Disabled PowerShell 2.0\"\r\n                }\r\n                catch {\r\n                    Write-Error $_\r\n                    Write-Host \"Unable to disable PowerShell 2.0\"\r\n                    exit 1\r\n                }\r\n            }\r\n            else {\r\n                Write-Host \"PowerShell is already disabled.\"\r\n            }\r\n        }\r\n        if (\r\n            $(Get-Command \"Disable-WindowsOptionalFeature\" -ErrorAction SilentlyContinue).Name -notlike \"Disable-WindowsOptionalFeature\" -and \r\n            $(Get-Command \"Uninstall-WindowsFeature\" -ErrorAction SilentlyContinue).Name -notlike \"Uninstall-WindowsFeature\"\r\n        ) {\r\n            Write-Host \"Running on an unsupported version of Windows.\"\r\n            exit 1\r\n        }\r\n    }\r\n    else {\r\n        Write-Host \"Please upgrade to 5.1 before disabling PowerShell 2.0.\"\r\n        exit 1\r\n    }\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Zugriff auf \u00fcber 300 Skripte im NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/de\/kostenlosetestversionformular\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>So verwenden Sie das Skript<\/h2>\n<p>Sie brauchen keine Parameter anzugeben. F\u00fchren Sie das Skript einfach mit administrativen Rechten aus. Das Skript f\u00fchrt Sie durch den Prozess und f\u00e4ngt sogar Fehler auf, um Sie zu informieren, wenn etwas schief l\u00e4uft.<\/p>\n<h2>Vorteile f\u00fcr IT-Fachleute und MSPs<\/h2>\n<p>F\u00fcr IT-Experten und MSPs ergeben sich daraus zwei Vorteile:<\/p>\n<ol>\n<li><strong>Erh\u00f6hte Sicherheit<\/strong>: Durch die Deaktivierung von PowerShell 2.0 schlie\u00dfen Sie eine Schwachstelle und machen so Ihr Netzwerk sicherer.<\/li>\n<li><strong>Effizienz<\/strong>: Anstatt manuell zu jedem Server und System zu navigieren, um PowerShell 2.0 zu deaktivieren, k\u00f6nnen Sie diese Aufgabe mit diesem Skript automatisieren.<\/li>\n<\/ol>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Die Deaktivierung von PowerShell 2.0 ist entscheidend f\u00fcr die Verbesserung der Sicherheit Ihrer Windows-Umgebung. F\u00fcr IT-Profis und MSPs, die nach einer effizienten M\u00f6glichkeit suchen, dies zu tun, ist unser Disable PowerShell 2.0-Skript ein Geschenk des Himmels. Es automatisiert die Aufgabe und ist mit Kontrollen ausgestattet, die sicherstellen, dass Sie alles richtig machen.<\/p>\n","protected":false},"author":35,"featured_media":206903,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[4280],"class_list":["post-208568","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows","use_cases-system-konfiguration"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/208568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=208568"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media\/206903"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=208568"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=208568"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=208568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}