{"id":208121,"date":"2023-09-27T08:49:40","date_gmt":"2023-09-27T08:49:40","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/abilitare-i-minidump-windows-powershell-2\/"},"modified":"2024-03-04T19:04:27","modified_gmt":"2024-03-04T19:04:27","slug":"abilitare-i-minidump-windows-powershell-2","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/it\/script-hub\/abilitare-i-minidump-windows-powershell-2\/","title":{"rendered":"Come abilitare i minidump in Windows utilizzando PowerShell"},"content":{"rendered":"<p><span class=\"TextRun SCXW76998254 BCX0\" lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW76998254 BCX0\">La pratica del debug e della risoluzione dei problemi dei sistemi informatici richiede spesso strumenti e script specializzati. Uno di questi metodi, fondamentale per molti esperti IT, \u00e8 l\u2019<\/span><span class=\"NormalTextRun SCXW76998254 BCX0\">utilizzo<\/span><span class=\"NormalTextRun SCXW76998254 BCX0\"> dei file minidump. Questi file offrono un&#8217;istantanea della memoria attiva quando un computer si blocca, <\/span><span class=\"NormalTextRun SCXW76998254 BCX0\">fornendo<\/span><span class=\"NormalTextRun SCXW76998254 BCX0\"> dati preziosi per l&#8217;analisi post-crash. Questo articolo esamina uno <strong>script PowerShell progettato per abilitare i minidump in modo automatico sui sistemi Windows<\/strong>.<\/span><\/span><\/p>\n<h2>Background<\/h2>\n<p><span class=\"TextRun SCXW90199607 BCX0\" lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW90199607 BCX0\">Per i professionisti IT e i provider di servizi gestiti (MSP), la capacit\u00e0 di acquisire e analizzare i dati sui crash di sistema \u00e8 fondamentale. Questo aiuta a capire perch\u00e9 un sistema si \u00e8 bloccato e a prevenire eventi futuri dello stesso genere. <\/span><span class=\"NormalTextRun SCXW90199607 BCX0\">I file minidump, in particolare, forniscono dati sufficienti senza consumare molto spazio su disco, il che li rende la scelta preferita di molti esperti.<\/span><span class=\"NormalTextRun SCXW90199607 BCX0\"> Tuttavia, l&#8217;impostazione manuale per generare e abilitare i minidump pu\u00f2 essere noiosa, ed \u00e8 qui che entra in gioco l&#8217;automazione. Utilizzando script come quello <\/span><span class=\"NormalTextRun SCXW90199607 BCX0\">che stiamo<\/span><span class=\"NormalTextRun SCXW90199607 BCX0\"> esaminando, i professionisti possono impostare in modo efficiente i loro sistemi per generare minidump quando <\/span><span class=\"NormalTextRun SCXW90199607 BCX0\">necessario<\/span><span class=\"NormalTextRun SCXW90199607 BCX0\">.<\/span><\/span><\/p>\n<h2>Lo script per abilitare i minidump<\/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>Accedi a oltre 300 script nel Dojo di NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/it\/prova-gratuita\/\">Ottieni l&#8217;accesso<\/a><\/p>\n<\/div>\n<h2>Analisi dettagliata<\/h2>\n<p><span data-contrast=\"none\">Lo script PowerShell per abilitare i minidump inizia controllando se il sistema ha i privilegi di amministratore. Questo \u00e8 fondamentale perch\u00e9 le modifiche al registro di sistema, effettuate da questo script per abilitare i minidump, richiedono tali autorizzazioni.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Il percorso principale del Registro di sistema che ci interessa \u00e8 <\/span><b><span data-contrast=\"none\">HKLM:SystemCurrentControlSetControlCrashControl<\/span><\/b><span data-contrast=\"none\">. All&#8217;interno di questo percorso, c&#8217;\u00e8 una chiave di registro specifica, <\/span><b><span data-contrast=\"none\">CrashDumpEnabled<\/span><\/b><span data-contrast=\"none\"> che regola lo stato di generazione dei crash dump.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Se questa chiave \u00e8 impostata su <\/span><b><span data-contrast=\"none\">0<\/span><\/b><span data-contrast=\"none\"> o non esiste, significa che i crash dump non sono abilitati. Lo script provveder\u00e0 quindi ad abilitare la creazione di minidump. Inoltre, lo script controlla la presenza di un pagefile e ne crea uno se manca, poich\u00e9 \u00e8 un prerequisito per abilitare i minidump.<\/span><\/p>\n<h2>Situazioni d&#8217;uso potenziali<\/h2>\n<p><span class=\"TextRun SCXW158797557 BCX0\" lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW158797557 BCX0\">Immagina un professionista IT, <\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">Bob<\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">, che lavora in un&#8217;organizzazione di medie dimensioni. In seguito a diversi crash inspiegabili del sistema, <\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">Bob<\/span><span class=\"NormalTextRun SCXW158797557 BCX0\"> \u00e8 sotto pressione per individuare la causa principale del problema. Invece di procedere macchina per macchina, <\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">Bob<\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">\u00a0<\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">distribuisce questo script su tutti i computer dell&#8217;organizzazione per abilitare i minidump. Questo approccio proattivo garantisce che la prossima volta che si verificher\u00e0 un crash, <\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">Bob <\/span>avr\u00e0<span class=\"NormalTextRun SCXW158797557 BCX0\"> un file minidump pronto per l&#8217;analisi<\/span>. <span class=\"NormalTextRun SCXW158797557 BCX0\">Ottimo lavoro<\/span><span class=\"NormalTextRun SCXW158797557 BCX0\">, Bob!<\/span><\/span><\/p>\n<h2>Approccio alternativo<\/h2>\n<p><span class=\"TextRun SCXW35656096 BCX0\" lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW35656096 BCX0\">Utilizzando metodi tradizionali, generare e abilitare i minidump comporta la navigazione in pi\u00f9 menu di Windows o la modifica manuale del registro di sistema, operazioni che richiedono tempo e sono soggette a errori. Questo script per abilitare i minidump si distingue per l&#8217;automazione del processo, riducendo cos\u00ec la possibilit\u00e0 di <\/span><span class=\"NormalTextRun SCXW35656096 BCX0\">errore<\/span><span class=\"NormalTextRun SCXW35656096 BCX0\"> umano e garantendo una configurazione coerente su pi\u00f9 macchine<\/span>.<\/span><\/p>\n<h2>Domande frequenti<\/h2>\n<ul>\n<li><span data-contrast=\"none\">Quali sono i prerequisiti per utilizzare questo script per abilitare i minidump?<\/span><br \/>\n<span data-contrast=\"none\">Lo script per abilitare i minidump supporta Windows 10 e Windows Server 2016 o versioni pi\u00f9 recenti.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">\u00c8 necessario un riavvio dopo l&#8217;esecuzione dello script per abilitare i minidump?<\/span><br \/>\n<span data-contrast=\"none\">Potrebbe essere necessario un riavvio per completare l&#8217;abilitazione dei mini-crash dump.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Cosa succede se il mio sistema ha gi\u00e0 abilitato i crash dump?<\/span><br \/>\n<span data-contrast=\"none\">Lo script per abilitare i minidump lo riconoscer\u00e0 e non apporter\u00e0 modifiche.<\/span><\/li>\n<\/ul>\n<h2>Implicazioni<\/h2>\n<p><span class=\"TextRun SCXW113353455 BCX0\" lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW113353455 BCX0\">Abilitare i minidump \u00e8 un&#8217;arma a doppio taglio. Se da un lato offre dati preziosi per il debug, dall&#8217;altro potrebbe <\/span><span class=\"NormalTextRun SCXW113353455 BCX0\">comportare<\/span><span class=\"NormalTextRun SCXW113353455 BCX0\"> la manipolazione di informazioni sensibili. I professionisti IT dovrebbero prendere in considerazione la possibilit\u00e0 di criptare questi file o di assicurarsi che <\/span><span class=\"NormalTextRun SCXW113353455 BCX0\">siano<\/span><span class=\"NormalTextRun SCXW113353455 BCX0\"> archiviati in luoghi sicuri<\/span>.<\/span><\/p>\n<h2>Suggerimenti<\/h2>\n<ul>\n<li><span data-contrast=\"none\">Testare sempre lo script per abilitare i minidump in un ambiente controllato prima di distribuirlo.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Esaminare e cancellare regolarmente i file minidump per risparmiare spazio su disco e mantenere la privacy.<\/span><\/li>\n<\/ul>\n<h2>Considerazioni finali<\/h2>\n<p><span class=\"TextRun SCXW264597958 BCX0\" lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW264597958 BCX0\">L&#8217;integrazione di soluzioni automatizzate, come lo script per abilitare i minidump descritto, semplifica le <a href=\"https:\/\/www.ninjaone.com\/it\/gestione-dei-ticket\">attivit\u00e0 di gestione IT<\/a>. Piattaforme come <\/span><span class=\"NormalTextRun SCXW264597958 BCX0\">NinjaOne <\/span>migliorano<span class=\"NormalTextRun SCXW264597958 BCX0\"> ulteriormente questo aspetto, offrendo un controllo centralizzato e una suite di strumenti personalizzati per le esigenze dei professionisti IT, e garantendo che i sistemi <\/span><span class=\"NormalTextRun SCXW264597958 BCX0\">rimangano<\/span><span class=\"NormalTextRun SCXW264597958 BCX0\"> ottimizzati e sicuri<\/span>.<\/span><span class=\"EOP SCXW264597958 BCX0\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n","protected":false},"author":35,"featured_media":207150,"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":[4275],"class_list":["post-208121","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub\/208121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/comments?post=208121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/media\/207150"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/media?parent=208121"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/operating_system?post=208121"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/use_cases?post=208121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}