{"id":811712,"date":"2026-05-25T07:03:27","date_gmt":"2026-05-25T07:03:27","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=811712"},"modified":"2026-05-25T07:03:27","modified_gmt":"2026-05-25T07:03:27","slug":"como-configurar-a-autenticacao-do-ntlm-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/como-configurar-a-autenticacao-do-ntlm-powershell\/","title":{"rendered":"Como definir a autentica\u00e7\u00e3o NTLM no Windows usando o PowerShell"},"content":{"rendered":"<p>Em um cen\u00e1rio de <a href=\"https:\/\/www.ninjaone.com\/it-hub\/seguranca-de-endpoints\/what-is-cybersecurity\/\">seguran\u00e7a cibern\u00e9tica<\/a> em constante evolu\u00e7\u00e3o, \u00e9 fundamental proteger as comunica\u00e7\u00f5es e a troca de dados. Um desses protocolos que tem sido um ponto focal de discuss\u00e3o \u00e9 o NTLM (NT LAN Manager), que \u00e9 usado para autenticar usu\u00e1rios em ambientes Microsoft. Com os recentes avan\u00e7os e preocupa\u00e7\u00f5es com a seguran\u00e7a, houve uma mudan\u00e7a das vers\u00f5es mais antigas do NTLM para o NTLMv2, mais seguro. Hoje, vamos nos aprofundar em um script do PowerShell que ajuda a gerenciar as respostas<strong> de autentica\u00e7\u00e3o NTLM<\/strong>, definindo o LmCompatibilityLevel no <a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-windows-registry\/\" target=\"_blank\" rel=\"noopener\">registro do Windows<\/a>.<\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>Originalmente desenvolvido como um protocolo de autentica\u00e7\u00e3o pela Microsoft, o NTLM passou por v\u00e1rias atualiza\u00e7\u00f5es para solucionar diversas vulnerabilidades de seguran\u00e7a. No entanto, com o surgimento de mecanismos de autentica\u00e7\u00e3o mais seguros, especialmente o NTLMv2, ficou evidente a necessidade de restringir ou desativar as vers\u00f5es mais antigas. Esse script ajuda os profissionais de TI e os <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a> a fazer essa transi\u00e7\u00e3o sem problemas, sem precisar navegar manualmente por configura\u00e7\u00f5es complexas do registro.<\/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    Set the LM and NTLMv1 authentication responses via LmCompatibilityLevel in the registry\r\n.DESCRIPTION\r\n    Set the LM and NTLMv1 authentication responses via LmCompatibilityLevel in the registry\r\n.EXAMPLE\r\n    No parameters needed.\r\n    Sets LAN Manager auth level to 5, \"Send NTLMv2 response only. Refuse LM &amp; NTLM.\"\r\n.EXAMPLE\r\n     -LmCompatibilityLevel 5\r\n    Sets LAN Manager auth level to 5, \"Send NTLMv2 response only. Refuse LM &amp; NTLM.\"\r\n.EXAMPLE\r\n     -LmCompatibilityLevel 3\r\n    Sets LAN Manager auth level to 3, \"Send NTLMv2 response only.\"\r\n    This is the default from Windows 7 and up.\r\n.EXAMPLE\r\n    PS C:&gt; Disable-LmNtlmV1.ps1 -LmCompatibilityLevel 5\r\n    Sets LAN Manager auth level to 5, \"Send NTLMv2 response only. Refuse LM &amp; NTLM.\"\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Reference chart: https:\/\/ss64.com\/nt\/syntax-ntlm.html\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.COMPONENT\r\n    ProtocolSecurity\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [ValidateRange(0, 5)]\r\n    [int]\r\n    $LmCompatibilityLevel = 5\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        if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))\r\n        { Write-Output $true }\r\n        else\r\n        { Write-Output $false }\r\n    }\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        New-Item -Path $Path -Force -ErrorAction SilentlyContinue | Out-Null\r\n        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {\r\n            Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false | Out-Null\r\n        }\r\n        else {\r\n            New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false | Out-Null\r\n        }\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    $Path = @(\r\n        \"HKLM:SYSTEMCurrentControlSetServicesLsa\"\r\n        \"HKLM:SYSTEMCurrentControlSetControlLSA\"\r\n    )\r\n    $Name = \"LmCompatibilityLevel\"\r\n    # $Value = $LmCompatibilityLevel\r\n    # Sets LmCompatibilityLevel to $LmCompatibilityLevel\r\n    try {\r\n        $Path | ForEach-Object {\r\n            Set-ItemProp -Path $_ -Name $Name -Value $LmCompatibilityLevel\r\n        }\r\n        \r\n    }\r\n    catch {\r\n        Write-Error $_\r\n        exit 1\r\n    }\r\n    $Path | ForEach-Object {\r\n        $Value = Get-ItemPropertyValue -Path $_ -Name $Name -ErrorAction SilentlyContinue\r\n        if ($null -eq $Value) {\r\n            Write-Host \"$_$Name set to: OS's default value(3).\"\r\n        }\r\n        else {\r\n            Write-Host \"$_$Name set to: $Value\"\r\n        }\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 roteiro \u00e9 essencialmente dividido em tr\u00eas fases: <em>in\u00edcio<\/em>, <em>processo<\/em> e <em>fim<\/em>.<\/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>Iniciar fase<\/strong>: O script come\u00e7a com a defini\u00e7\u00e3o de duas fun\u00e7\u00f5es:<\/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>Test-IsElevated<\/strong>: Verifica se o script \u00e9 executado com privil\u00e9gios de administrador.<\/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>Set-ItemProp<\/strong>: Cria ou define uma propriedade de chave de registro.<\/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=\"4\" data-aria-level=\"1\"><strong>Fase do processo<\/strong>: Ele verifica se o usu\u00e1rio tem direitos elevados. Caso contr\u00e1rio, um erro \u00e9 sinalizado. Caso contr\u00e1rio, ele modifica o <strong>LmCompatibilityLevel<\/strong> em dois poss\u00edveis caminhos de registro. Ap\u00f3s a modifica\u00e7\u00e3o, o script confirma a configura\u00e7\u00e3o aplicada.<\/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=\"5\" data-aria-level=\"1\"><strong>Fase final<\/strong>: N\u00e3o \u00e9 usado explicitamente, mas \u00e9 um espa\u00e7o reservado para poss\u00edveis atualiza\u00e7\u00f5es ou extens\u00f5es futuras do script.<\/li>\n<\/ul>\n<h2>Casos de uso em potencial<\/h2>\n<p><em>Estudo de caso<\/em>: Imagine Jenny, uma administradora de TI em uma organiza\u00e7\u00e3o de m\u00e9dio porte. Recentemente, eles passaram por uma auditoria de seguran\u00e7a, revelando que alguns sistemas ainda usam vers\u00f5es desatualizadas do NTLM. Com centenas de m\u00e1quinas para gerenciar, n\u00e3o \u00e9 poss\u00edvel atualizar manualmente cada uma delas. Usando esse script, Jenny atualiza sem problemas todos os sistemas, garantindo que eles aceitem apenas respostas NTLMv2.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Embora a Pol\u00edtica de Grupo tamb\u00e9m possa ser usada para gerenciar as configura\u00e7\u00f5es NTLM em uma organiza\u00e7\u00e3o, os scripts do PowerShell, como o discutido, oferecem mais granularidade e automa\u00e7\u00e3o. Elas podem ser integradas a ferramentas de automa\u00e7\u00e3o ou fluxos de trabalho maiores, tornando o processo simplificado e menos propenso a erros manuais.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>Ao definir o LmCompatibilityLevel, os profissionais de TI determinam como os sistemas lidam com a autentica\u00e7\u00e3o NTLM. A restri\u00e7\u00e3o ao NTLMv2 aumenta a seguran\u00e7a, reduzindo os riscos associados a vers\u00f5es mais antigas e menos seguras. No entanto, \u00e9 fundamental garantir a compatibilidade, pois sistemas ou aplicativos mais antigos podem enfrentar problemas de conectividade ap\u00f3s as altera\u00e7\u00f5es.<\/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\">Sempre fa\u00e7a backup do estado atual do registro antes de fazer altera\u00e7\u00f5es.<\/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\">Inicialmente, teste o script em um ambiente controlado para entender seu impacto.<\/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\">Mantenha-se informado sobre as pr\u00e1ticas recomendadas de seguran\u00e7a mais recentes e integre-as em suas auditorias de rotina.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>Embora scripts do PowerShell como esses capacitem os profissionais de TI a aprimorar a seguran\u00e7a, <a href=\"https:\/\/www.ninjaone.com\/pt-br\/rmm\/\">ferramentas de monitoramento e gerenciamento como o NinjaOne<\/a> elevam ainda mais esses recursos. Com <a href=\"https:\/\/www.ninjaone.com\/pt-br\/rmm\/automacao-de-ti\/\">monitoramento, automa\u00e7\u00e3o e relat\u00f3rios<\/a> integrados <a href=\"https:\/\/www.ninjaone.com\/pt-br\/rmm\/automacao-de-ti\/\">,<\/a> plataformas como o NinjaOne garantem que sua infraestrutura de TI permane\u00e7a robusta, segura e eficiente, complementando scripts e interven\u00e7\u00f5es manuais.<\/p>\n<p>Lembre-se de que, no \u00e2mbito da TI, as medidas proativas, combinadas com as ferramentas certas, abrem caminho para <a href=\"https:\/\/www.ninjaone.com\/pt-br\/gestao-ti-empresarial\/seguranca\/\">uma seguran\u00e7a aprimorada e um gerenciamento eficiente do sistema<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"author":35,"featured_media":144862,"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-811712","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\/811712","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=811712"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/144862"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=811712"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=811712"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=811712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}