{"id":808449,"date":"2026-05-18T07:01:23","date_gmt":"2026-05-18T07:01:23","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=808449"},"modified":"2026-05-18T07:01:23","modified_gmt":"2026-05-18T07:01:23","slug":"ativar-minidumps-no-windows-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/ativar-minidumps-no-windows-powershell\/","title":{"rendered":"Como habilitar minidumps no Windows usando o PowerShell"},"content":{"rendered":"<p>A pr\u00e1tica de depura\u00e7\u00e3o e solu\u00e7\u00e3o de problemas de sistemas de computador geralmente exige ferramentas e scripts especializados. Um desses m\u00e9todos, crucial para muitos especialistas em TI, \u00e9 a utiliza\u00e7\u00e3o de arquivos minidump. Esses arquivos oferecem um instant\u00e2neo da mem\u00f3ria ativa quando um computador sofre uma pane, fornecendo dados valiosos para an\u00e1lise p\u00f3s-pane. Este artigo examina um <strong>script do PowerShell projetado para automatizar a ativa\u00e7\u00e3o de minidumps em sistemas Windows<\/strong>.<\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>Para profissionais de TI e <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a>, a capacidade de capturar e analisar dados de falhas \u00e9 vital. Isso os ajuda a entender por que um sistema falhou e a evitar futuras ocorr\u00eancias. <a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-a-windows-minidump-file\/\">Os arquivos Minidump<\/a>, em particular, fornecem dados suficientes sem <a href=\"https:\/\/www.ninjaone.com\/blog\/free-up-disk-space\/\">consumir muito espa\u00e7o em disco<\/a>, o que os torna a escolha preferida de muitos especialistas. No entanto, a configura\u00e7\u00e3o manual da gera\u00e7\u00e3o de minidump pode ser entediante, e \u00e9 a\u00ed que entra a automa\u00e7\u00e3o. Ao usar scripts como o que estamos analisando, os profissionais podem configurar seus sistemas de forma eficiente para gerar minidumps quando necess\u00e1rio.<\/p>\n<h2>O roteiro<\/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 style=\"text-align: center;\">Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Detalhamento<\/h2>\n<p>O script do PowerShell em foco come\u00e7a verificando se o sistema tem privil\u00e9gios de administrador. Isso \u00e9 fundamental porque as altera\u00e7\u00f5es no registro do sistema, conforme pretendido por esse script, exigem essas permiss\u00f5es.<\/p>\n<p>O principal caminho de registro de interesse \u00e9 <strong>HKLM:SystemCurrentControlSetControlCrashControl<\/strong>. Nesse caminho, h\u00e1 uma chave de registro espec\u00edfica, <strong>CrashDumpEnabled<\/strong>, que controla o estado da gera\u00e7\u00e3o de despejos de falhas.<\/p>\n<p>Se essa chave for definida como <strong>0<\/strong> ou n\u00e3o existir, isso indica que os despejos de colis\u00f5es n\u00e3o est\u00e3o ativados. Em seguida, o script executar\u00e1 as etapas para ativar a cria\u00e7\u00e3o de minidump. Al\u00e9m disso, o script verifica a presen\u00e7a de um arquivo de p\u00e1gina e estabelece um, se estiver faltando, pois \u00e9 um pr\u00e9-requisito para a cria\u00e7\u00e3o de minidumps.<\/p>\n<h2>Casos de uso em potencial<\/h2>\n<p>Considere um profissional de TI, Bob, que trabalha em uma organiza\u00e7\u00e3o de m\u00e9dio porte. Ap\u00f3s v\u00e1rias falhas inexplic\u00e1veis no sistema, Bob est\u00e1 sob press\u00e3o para descobrir a causa principal. Em vez de fazer isso m\u00e1quina por m\u00e1quina, Bob\u00a0implementa esse script em todos os computadores da organiza\u00e7\u00e3o. Essa abordagem proativa garante que, na pr\u00f3xima vez que ocorrer uma falha, Bob ter\u00e1 um arquivo de minidump pronto para an\u00e1lise. Bom trabalho, Bob!<\/p>\n<h2>Abordagem alternativa<\/h2>\n<p>Tradicionalmente, a ativa\u00e7\u00e3o da gera\u00e7\u00e3o de minidump envolve a navega\u00e7\u00e3o em v\u00e1rios menus do Windows ou a edi\u00e7\u00e3o manual do registro, tarefas que consomem muito tempo e s\u00e3o propensas a erros. Esse script se destaca por automatizar o processo, reduzindo assim a chance de erro humano e garantindo uma configura\u00e7\u00e3o consistente em v\u00e1rias m\u00e1quinas.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>A ativa\u00e7\u00e3o da gera\u00e7\u00e3o de minidump \u00e9 uma faca de dois gumes. Embora ofere\u00e7a dados valiosos para depura\u00e7\u00e3o, pode conter informa\u00e7\u00f5es confidenciais. Os profissionais de TI devem considerar a possibilidade de criptografar esses arquivos ou garantir que eles sejam armazenados em locais seguros.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li>Sempre teste o script em um ambiente controlado antes de implement\u00e1-lo.<\/li>\n<li>Revise e limpe regularmente os arquivos de minidump para economizar espa\u00e7o em disco e manter a privacidade.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>A incorpora\u00e7\u00e3o de solu\u00e7\u00f5es automatizadas, como o script discutido, simplifica <a href=\"https:\/\/www.ninjaone.com\/pt-br\/ticketing-software\/\">as tarefas de gerenciamento de TI<\/a>. Plataformas como o NinjaOne aumentam ainda mais isso, oferecendo controle centralizado e um conjunto de ferramentas adaptadas \u00e0s necessidades dos profissionais de TI, garantindo que os sistemas permane\u00e7am otimizados e seguros.<\/p>\n","protected":false},"author":35,"featured_media":142523,"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":[12456],"class_list":["post-808449","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/808449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=808449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/142523"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=808449"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=808449"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=808449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}