{"id":208607,"date":"2024-01-17T13:30:00","date_gmt":"2024-01-17T13:30:00","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/desactivar-powershell-2-0\/"},"modified":"2024-03-04T17:51:23","modified_gmt":"2024-03-04T17:51:23","slug":"desactivar-powershell-2-0","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/desactivar-powershell-2-0\/","title":{"rendered":"C\u00f3mo desactivar PowerShell 2.0: gu\u00eda con el script"},"content":{"rendered":"<p>\u00a1Hola, profesional de la tecnolog\u00eda! Si eres administrador de TI o trabajas en el sector de los servicios gestionados (MSP), sabr\u00e1s que mantener la seguridad de tu entorno es tu m\u00e1xima prioridad. Un \u00e1rea que a menudo necesita ser examinada es la configuraci\u00f3n de PowerShell en los sistemas Windows. Hablemos, pues, de <strong>PowerShell 2.0 y de por qu\u00e9 conviene desactivarlo<\/strong>. O, mejor a\u00fan, hablemos de script que lo haga por ti.<\/p>\n<h2>\u00bfPor qu\u00e9 desactivar PowerShell 2.0?<\/h2>\n<p>En primer lugar, vamos a tratar de entender por qu\u00e9 querr\u00edas desactivar PowerShell 2.0. Esta versi\u00f3n heredada de PowerShell no cuenta con muchas de las funciones y mejoras de seguridad disponibles en las versiones m\u00e1s recientes. Es pr\u00e1cticamente una invitaci\u00f3n abierta a los actores malintencionados para que exploten tus sistemas.<\/p>\n<h2>El script para desactivar PowerShell 2.0<\/h2>\n<p>Ahora que hemos establecido el \u00abpor qu\u00e9\u00bb, hablemos del \u00abc\u00f3mo\u00bb. El script Disable PowerShell 2.0 es una soluci\u00f3n integral. Escrito en PowerShell 5.1, el script est\u00e1 dise\u00f1ado para funcionar en Windows 10, Windows Server 2016 y superiores.<\/p>\n<h3><strong>Esto es lo que ofrece este script:<\/strong><\/h3>\n<h4><em>Control de privilegios elevados<\/em><\/h4>\n<p>El script realiza una comprobaci\u00f3n inicial para ver si se est\u00e1 ejecutando con privilegios de administrador y, si no es as\u00ed, te avisar\u00e1 para que lo ejecutes como administrador.<\/p>\n<h4><em>Comprobaci\u00f3n del sistema operativo y la versi\u00f3n<\/em><\/h4>\n<p>Antes de intentar eliminar PowerShell 2.0, comprueba tu versi\u00f3n de PowerShell. Tienes que ejecutar PowerShell 5.1 o posteriores. Es una funci\u00f3n \u00fatil, que te evita crear problemas en tu configuraci\u00f3n actual.<\/p>\n<h4><em>La eliminaci\u00f3n<\/em><\/h4>\n<p>El script emplea diferentes comandos(<em>Disable-WindowsOptionalFeaturey Uninstall-WindowsFeature<\/em>) en funci\u00f3n de cu\u00e1l sea tu sistema operativo para desactivar PowerShell 2.0. Si PowerShell 2.0 ya est\u00e1 desactivado, te lo har\u00e1 saber.<\/p>\n<h2>El script<\/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>Accede a m\u00e1s de 300 scripts en el Dojo de NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/es\/prueba-gratuita-formulario\/\">Obt\u00e9n acceso<\/a><\/p>\n<\/div>\n<h2>C\u00f3mo utilizar el script<\/h2>\n<p>No necesitas proporcionar ning\u00fan par\u00e1metro; basta con ejecutar el script con privilegios administrativos. El script te guiar\u00e1 a trav\u00e9s del proceso e incluso detectar\u00e1 errores para avisarte si algo va mal.<\/p>\n<h2>Ventajas para los profesionales de TI y los MSP<\/h2>\n<p>Para los profesionales de TI y los MSP, las ventajas son dobles:<\/p>\n<ol>\n<li><strong>Seguridad reforzada<\/strong>: al desactivar PowerShell 2.0, est\u00e1s cerrando un punto vulnerable, con lo que tu red ser\u00e1 m\u00e1s segura.<\/li>\n<li><strong>Eficacia<\/strong>: En lugar de ir manualmente a cada servidor y sistema para desactivar PowerShell 2.0, puedes automatizar esta tarea con este script.<\/li>\n<\/ol>\n<h2>Reflexiones finales<\/h2>\n<p>Desactivar PowerShell 2.0 es crucial para mejorar la seguridad de tu entorno Windows. Para los profesionales de TI y los MSP que buscan una forma eficaz de hacerlo, nuestro script PowerShell 2.0 es una bendici\u00f3n, ya que automatiza la tarea y viene equipado con comprobaciones para asegurarte de que est\u00e1s haciendo las cosas bien.<\/p>\n","protected":false},"author":35,"featured_media":206909,"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":[4265],"class_list":["post-208607","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/208607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/comments?post=208607"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media\/206909"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=208607"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=208607"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=208607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}