{"id":208631,"date":"2024-02-05T15:39:07","date_gmt":"2024-02-05T15:39:07","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/archivos-de-minivolcado-powershell\/"},"modified":"2024-03-04T20:45:46","modified_gmt":"2024-03-04T20:45:46","slug":"archivos-de-minivolcado-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/archivos-de-minivolcado-powershell\/","title":{"rendered":"C\u00f3mo activar archivos de minivolcado en Windows mediante PowerShell"},"content":{"rendered":"<p>La pr\u00e1ctica de depurar y solucionar problemas en sistemas inform\u00e1ticos suele requerir herramientas y scripts especializados. Uno de estos m\u00e9todos, crucial para muchos expertos en TI, es la utilizaci\u00f3n de archivos de minivolcado. Estos archivos ofrecen una instant\u00e1nea de la memoria activa cuando un ordenador se bloquea, proporcionando datos muy valiosos para el an\u00e1lisis posterior al fallo. En este post veremos un <strong>script PowerShell dise\u00f1ado para activar archivos de minivolcado en sistemas Windows autom\u00e1ticamente<\/strong>.<\/p>\n<h2>Antecedentes<\/h2>\n<p>Para los profesionales de TI y los proveedores de servicios gestionados (MSP), la capacidad de capturar y analizar sobre los crash del sistema es vital. Esto les ayuda a entender por qu\u00e9 se ha bloqueado un sistema y a evitar que vuelva a ocurrir en el futuro. Los <a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-a-windows-minidump-file\/\">archivos de minivolcado<\/a>, en particular, proporcionan los datos justos sin consumir mucho espacio en disco, lo que los convierte en la opci\u00f3n preferida de muchos expertos. Sin embargo, configurar manualmente la generaci\u00f3n de archivos de minivolcado puede resultar tedioso, y ah\u00ed es donde entra en juego la automatizaci\u00f3n. Utilizando scripts como el que nos ocupa, los profesionales pueden configurar eficazmente sus sistemas para generar archivos de minivolcado cuando sea necesario.<\/p>\n<h2>El script para activar archivos de minivolcado en Windows<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">&lt;#\r\n.SYNOPSIS\r\n    Turn on mini dumps if they are off, if other dumps are already enabled do not change the configuration.\r\n.DESCRIPTION\r\n    Turn on mini dumps if they are off, if other dumps are already enabled do not change the configuration.\r\n    This will enable the creation of the pagefile, but set to automatically manage by Windows.\r\n    Reboot might be needed.\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes:\r\n    Initial Release\r\nBy 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[CmdletBinding()]\r\nparam ()\r\n\r\nbegin {\r\n    function Set-ItemProp {\r\n        param (\r\n            $Path,\r\n            $Name,\r\n            $Value,\r\n            [ValidateSet(\"DWord\", \"QWord\", \"String\", \"ExpandedString\", \"Binary\", \"MultiString\", \"Unknown\")]\r\n            $PropertyType = \"DWord\"\r\n        )\r\n        # Do not output errors and continue\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue\r\n        if (-not $(Test-Path -Path $Path)) {\r\n            # Check if path does not exist and create the path\r\n            New-Item -Path $Path -Force | Out-Null\r\n        }\r\n        if ((Get-ItemProperty -Path $Path -Name $Name)) {\r\n            # Update property and print out what it was changed from and changed to\r\n            $CurrentValue = Get-ItemProperty -Path $Path -Name $Name\r\n            try {\r\n                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Error $_\r\n            }\r\n            Write-Host \"$Path$Name changed from $CurrentValue to $(Get-ItemProperty -Path $Path -Name $Name)\"\r\n        }\r\n        else {\r\n            # Create property with value\r\n            try {\r\n                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Error $_\r\n            }\r\n            Write-Host \"Set $Path$Name to $(Get-ItemProperty -Path $Path -Name $Name)\"\r\n        }\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue\r\n    }\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\r\n    # Reference: https:\/\/learn.microsoft.com\/en-US\/troubleshoot\/windows-server\/performance\/memory-dump-file-options\r\n    $Path = \"HKLM:SystemCurrentControlSetControlCrashControl\"\r\n    $Name = \"CrashDumpEnabled\"\r\n    $CurrentValue = Get-ItemPropertyValue -Path $Path -Name $Name -ErrorAction SilentlyContinue\r\n    $Value = 3\r\n\r\n    # If CrashDumpEnabled is set to 0 or doesn't exist then enable mini crash dump\r\n    if ($CurrentValue -eq 0 -and $null -ne $CurrentValue) {\r\n        $PageFile = Get-ItemPropertyValue -Path \"HKLM:SYSTEMCurrentControlSetControlSession ManagerMemory Management\" -Name PagingFiles -ErrorAction SilentlyContinue\r\n        if (-not $PageFile) {\r\n            # If the pagefile was not setup, create the registry entry needed to create the pagefile\r\n            try {\r\n                # Enable automatic page management file if disabled to allow mini dump to function\r\n                Set-ItemProp -Path \"HKLM:SYSTEMCurrentControlSetControlSession ManagerMemory Management\" -Name PagingFiles -Value \"?:pagefile.sys\" -PropertyType MultiString\r\n            }\r\n            catch {\r\n                Write-Error \"Could not create pagefile.\"\r\n                exit 1\r\n            }\r\n        }\r\n        Set-ItemProp -Path $Path -Name $Name -Value 3\r\n        Write-Host \"Reboot might be needed to enable mini crash dump.\"\r\n    }\r\n    else {\r\n        Write-Host \"Crash dumps are already enabled.\"\r\n    }\r\n    exit 0\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>Descripci\u00f3n detallada<\/h2>\n<p>El script PowerShell en cuesti\u00f3n comienza comprobando si el sistema tiene privilegios de administrador. Esto es crucial porque los cambios en el registro del sistema, como pretende este script, requieren dichos permisos.<\/p>\n<p>La principal ruta de registro de inter\u00e9s es <strong>HKLM:SystemCurrentControlSetControlCrashControl<\/strong>. Dentro de esta ruta, hay una clave de registro espec\u00edfica, <strong>CrashDumpEnabled<\/strong>, que gobierna el estado de la generaci\u00f3n de archivos de volcado de error.<\/p>\n<p>Si esta clave es <strong>0<\/strong> o no existe, indica que los volcados de crash no est\u00e1n habilitados. Seguidamente el script toma medidas para activar la creaci\u00f3n de archivos de minivolcado. Adem\u00e1s, el script comprueba la presencia de un archivo de p\u00e1ginas y establece uno si falta, ya que es un requisito previo para la creaci\u00f3n de archivos de minivolcado.<\/p>\n<h2>Posibles casos de uso<\/h2>\n<p>Pensemos en un profesional de TI, Daniel, que trabaja en una empresa mediana. Tras varias ca\u00eddas inexplicables del sistema, Daniel est\u00e1 bajo presi\u00f3n para averiguar la causa del problema. En lugar de ir m\u00e1quina por m\u00e1quina, Daniel\u00a0despliega este script en todos los ordenadores de la organizaci\u00f3n. Este enfoque proactivo Daniel que la pr\u00f3xima vez que se produzca un fallo, Bob tendr\u00e1 un archivo de minivolcado listo para su an\u00e1lisis. \u00a1Buen trabajo, Daniel!<\/p>\n<h2>Enfoque alternativo<\/h2>\n<p>Tradicionalmente, habilitar la generaci\u00f3n de archivos de minivolcado implica navegar por m\u00faltiples men\u00fas de Windows o editar manualmente el registro, tareas que consumen mucho tiempo y son propensas a errores. Este script destaca por automatizar el proceso, reduciendo as\u00ed la posibilidad de errores humanos y garantizando una configuraci\u00f3n coherente en varias m\u00e1quinas.<\/p>\n<h2>Preguntas frecuentes<\/h2>\n<ul>\n<li>\u00bfCu\u00e1les son los requisitos previos para utilizar este script?<br \/>\nEl script es compatible con Windows 10 y Windows Server 2016 o posterior.<\/li>\n<li>\u00bfEs necesario reiniciar despu\u00e9s de ejecutar el script?<br \/>\nEs posible que sea necesario reiniciar para finalizar la habilitaci\u00f3n de los archivos de minivolcado.<\/li>\n<li>\u00bfQu\u00e9 ocurre si mi sistema ya tiene activados los volcados de memoria?<br \/>\nEl script lo reconocer\u00e1 y no realizar\u00e1 cambios.<\/li>\n<\/ul>\n<h2>Implicaciones<\/h2>\n<p>Activar la generaci\u00f3n de archivos de minivolado es un arma de doble filo. Aunque ofrece datos valiosos para la depuraci\u00f3n, podr\u00eda contener informaci\u00f3n sensible. Los profesionales de TI deber\u00edan considerar la posibilidad de cifrar estos archivos o asegurarse de que se almacenan en ubicaciones seguras.<\/p>\n<h2>Recomendaciones<\/h2>\n<ul>\n<li>Prueba siempre el script en un entorno controlado antes de desplegarlo.<\/li>\n<li>Revisa y borra regularmente los archivos de minivolcado para ahorrar espacio en disco y mantener la privacidad.<\/li>\n<\/ul>\n<h2>Reflexiones finales<\/h2>\n<p>La incorporaci\u00f3n de soluciones automatizadas, como el script que hemos visto, simplifica <a href=\"https:\/\/www.ninjaone.com\/es\/ticketing-software\/\">las tareas de gesti\u00f3n de TI<\/a>. Plataformas como NinjaOne aumentan a\u00fan m\u00e1s este aspecto al ofrecer un control centralizado y un conjunto de herramientas adaptadas a las necesidades de los profesionales de TI, garantizando que los sistemas permanezcan optimizados y seguros.<\/p>\n","protected":false},"author":35,"featured_media":207155,"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-208631","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\/208631","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=208631"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media\/207155"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=208631"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=208631"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=208631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}