{"id":810789,"date":"2026-05-21T12:00:52","date_gmt":"2026-05-21T12:00:52","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=810789"},"modified":"2026-05-21T12:00:52","modified_gmt":"2026-05-21T12:00:52","slug":"como-aumentar-o-tamanho-do-arquivo-de-registro-de-eventos-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/como-aumentar-o-tamanho-do-arquivo-de-registro-de-eventos-powershell\/","title":{"rendered":"Como aumentar de forma eficiente o tamanho do arquivo de registro de eventos com o PowerShell"},"content":{"rendered":"<p>Os logs de eventos em plataformas Windows oferecem informa\u00e7\u00f5es valiosas sobre as opera\u00e7\u00f5es do sistema e poss\u00edveis problemas. Dessa forma, os profissionais de TI precisam de uma maneira de ajustar o tamanho desses registros para acomodar diferentes requisitos. Este artigo se aprofunda em um script do PowerShell criado especificamente para aqueles que querem saber <strong>como aumentar o tamanho do arquivo de registro de eventos<\/strong>, garantindo que os sistemas estejam sempre sob vigil\u00e2ncia adequada.<\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>O PowerShell, a estrutura de automa\u00e7\u00e3o de tarefas da Microsoft, tornou-se uma ferramenta indispens\u00e1vel para profissionais de TI em todo o mundo. Entre seus in\u00fameros recursos est\u00e1 a capacidade de modificar as configura\u00e7\u00f5es do sistema, incluindo o tamanho dos registros de eventos. Como os sistemas geram grandes quantidades de registros ao longo do tempo, ter a capacidade de ajustar a capacidade de armazenamento desses registros \u00e9 fundamental para os <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a> e administradores de TI.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Changes the max size for the specified Event Logs.\r\n.DESCRIPTION\r\n    Changes the max size for the specified Event Logs.\r\n    Common log names used: Security, Application, System\r\n    To get a list of Event Log names from your system you can run:\r\n        Get-WinEvent -ListLog * | Select-Object LogName\r\n.EXAMPLE\r\n     -LogName Security -MaxSize 50MB\r\n    Changes the max log size for Security to 50MB\r\n.EXAMPLE\r\n     -LogName Security, Application, System -MaxSize 50MB\r\n    Changes the max log size for Security, Application, and System to 50MB\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Windows 10 defaults to 20MB \/ 20480KB\r\n\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\r\n[CmdletBinding(SupportsShouldProcess)]\r\nparam (\r\n    # Event Log name\r\n    # https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.management\/limit-eventlog?view=powershell-5.1#-logname\r\n    [Parameter(Mandatory = $true)]\r\n    [ValidateScript(\r\n        {\r\n            if ( -not $($_ | Where-Object { $_ -in $(Get-WinEvent -ListLog * | Select-Object LogName).LogName }) ) {\r\n                throw \"$_ is not a valid Event Log Name.\"\r\n            }\r\n            else {\r\n                $true\r\n            }\r\n        }\r\n    )]\r\n    [String[]]\r\n    $LogName,\r\n    # The max size of the event log storage in KB.\r\n    # Use KB, MB, or GB after your number like 111MB for example.\r\n    [Parameter(Mandatory = $true)]\r\n    [Int64]\r\n    [ValidateRange(64KB, 4GB)]\r\n    $MaxSize\r\n)\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\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    \"Used Parameters:\"\r\n    $(\r\n        $PSBoundParameters.Keys | ForEach-Object {\r\n            $Key = $_\r\n            $Value = $PSBoundParameters[\"$_\"] -join ', '\r\n            \"-$Key $Value\"\r\n        }\r\n    ) -join ' '\r\n\r\n    # Look for Event log names that don't exist\r\n    if ($($LogName | ForEach-Object { $_ -notin $(Get-WinEvent -ListLog * | Select-Object LogName).LogName })) {\r\n        $InvalidLogNames = $LogName | Where-Object { $_ -notin $(Get-WinEvent -ListLog * | Select-Object LogName).LogName }\r\n        Write-Error \"Invalid Log Names Found.\"\r\n        Write-Host \"Invalid Log Names: $($InvalidLogNames -join ', ')\"\r\n        exit 1\r\n    }\r\n\r\n    \"Current Log Sizes:\"\r\n    Get-WinEvent -ListLog $LogName | Select-Object LogName, MaximumSizeInBytes | ForEach-Object {\r\n        \"$($_.LogName): $($_.MaximumSizeInBytes \/ 1024)KB\"\r\n    }\r\n}\r\nprocess {\r\n    if ($PSCmdlet.ShouldProcess($($LogName -join ','), \"Limit-EventLog\")) {\r\n        Limit-EventLog -LogName $LogName -MaximumSize $MaxSize -ErrorAction Stop\r\n        # -ErrorAction Stop will exit and return an exit code of 1\r\n        \"Changed Log Sizes to:\"\r\n        Get-WinEvent -ListLog $LogName | Select-Object LogName, MaximumSizeInBytes | ForEach-Object {\r\n            \"$($_.LogName): $($_.MaximumSizeInBytes \/ 1024)KB\"\r\n        }\r\n    }\r\n    else {\r\n        # If -WhatIf was used then print out what the changes would have been.\r\n        \"Would have changed the max log size(s) of: $($LogName -join ',') to $($MaxSize \/ 1024)KB\"\r\n    }\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 come\u00e7a validando seus requisitos de ambiente. Em seguida, ele faz o seguinte:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Defini\u00e7\u00f5es de par\u00e2metros<\/strong>: S\u00e3o estabelecidos par\u00e2metros para especificar os nomes dos registros<strong>($LogName<\/strong>) e o tamanho m\u00e1ximo desejado<strong>($MaxSize<\/strong> ).<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Verifica\u00e7\u00e3o da eleva\u00e7\u00e3o<\/strong>: Uma fun\u00e7\u00e3o, <strong>Test-IsElevated<\/strong>, \u00e9 usada para garantir que o script seja executado com privil\u00e9gios administrativos, uma necessidade para modificar as propriedades do registro de eventos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Valida\u00e7\u00e3o do nome do registro<\/strong>: O script valida se os nomes de registro fornecidos existem no sistema usando o cmdlet <strong>Get-WinEvent<\/strong>.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Exibir os tamanhos atuais<\/strong>: Antes de fazer qualquer altera\u00e7\u00e3o, o script exibe os tamanhos atuais dos logs especificados.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Ajuste de tamanho<\/strong>: Se a valida\u00e7\u00e3o for aprovada e a aprova\u00e7\u00e3o do usu\u00e1rio for obtida (com a verifica\u00e7\u00e3o <strong>$PSCmdlet.ShouldProcess<\/strong> ), o cmdlet <strong>Limit-EventLog<\/strong> ajustar\u00e1 os tamanhos de registro para o valor desejado.<\/li>\n<\/ul>\n<h2>Casos de uso em potencial<\/h2>\n<p><strong>Estudo de caso:<\/strong> Imagine um administrador de TI de uma grande empresa em que os aplicativos essenciais produzem muitos registros diariamente. Regularmente, o registro de aplicativos fica cheio, fazendo com que os eventos mais recentes substituam os mais antigos. Usando esse script, o administrador pode aumentar facilmente o tamanho do registro de aplicativos para garantir que dados importantes n\u00e3o sejam perdidos.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Tradicionalmente, para aumentar o tamanho de um registro de eventos, era necess\u00e1rio navegar pela GUI do Event Viewer, clicar com o bot\u00e3o direito do mouse no registro desejado, selecionar &#8220;Propriedades&#8221; e ajustar o tamanho. O script oferece uma alternativa automatizada, eficiente e com redu\u00e7\u00e3o de erros. Ele tamb\u00e9m permite ajustes em lote, um recurso que n\u00e3o \u00e9 facilmente obtido com m\u00e9todos manuais.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>Embora o aumento do tamanho dos registros possa garantir a reten\u00e7\u00e3o de dados vitais, ele tamb\u00e9m tem implica\u00e7\u00f5es de armazenamento. Se as unidades do sistema estiverem pr\u00f3ximas da capacidade e os registros forem expandidos significativamente, isso poder\u00e1 resultar em problemas de falta de espa\u00e7o. Al\u00e9m disso, arquivos de registro maiores podem afetar ligeiramente a velocidade de determinadas consultas de registro.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Monitore regularmente o armazenamento ap\u00f3s aumentar o tamanho dos registros.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Ajuste os tamanhos dos registros somente quando necess\u00e1rio e tenha uma compreens\u00e3o clara do motivo.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Sempre mantenha os registros, especialmente o registro de seguran\u00e7a, em um estado monitorado para <a href=\"https:\/\/www.ninjaone.com\/blog\/common-cyber-attacks\/\">identificar poss\u00edveis amea\u00e7as \u00e0 seguran\u00e7a<\/a>.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>Para MSPs e profissionais de TI, ferramentas como o NinjaOne podem ser cruciais ao lidar com o <a href=\"https:\/\/www.ninjaone.com\/blog\/linux-log-management-best-practices\/\">gerenciamento de registros<\/a> e tarefas relacionadas. <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">O NinjaOne<\/a>, integrado a scripts como o discutido, pode simplificar ainda mais o gerenciamento do sistema, tornando mais f\u00e1cil do que nunca garantir a integridade e a seguran\u00e7a do sistema.<\/p>\n","protected":false},"author":35,"featured_media":144391,"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":[12460],"class_list":["post-810789","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\/810789","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=810789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/144391"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=810789"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=810789"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=810789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}