{"id":808025,"date":"2026-05-13T11:04:03","date_gmt":"2026-05-13T11:04:03","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=808025"},"modified":"2026-05-13T11:04:03","modified_gmt":"2026-05-13T11:04:03","slug":"como-desativar-smbv1-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/como-desativar-smbv1-powershell\/","title":{"rendered":"Como desativar o SMBv1 (Server Message Block Protocol) com o PowerShell"},"content":{"rendered":"<p>O <a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-smb-server-message-block\/\">Server Message Block Protocol (SMB)<\/a> j\u00e1 existe h\u00e1 algum tempo, servindo como espinha dorsal para o compartilhamento de arquivos e v\u00e1rias outras opera\u00e7\u00f5es de rede. No entanto, a vers\u00e3o mais antiga, SMBv1, agora \u00e9 vista como um problema devido a uma s\u00e9rie de vulnerabilidades de seguran\u00e7a. Se voc\u00ea \u00e9 um profissional de TI ou um provedor de servi\u00e7os gerenciados (MSP), garantir a seguran\u00e7a da rede deve ser sua principal preocupa\u00e7\u00e3o. Ent\u00e3o, <strong>como voc\u00ea faz para desativar o SMBv1<\/strong> de forma eficaz?<\/p>\n<h2>O que o script faz?<\/h2>\n<p>O script do PowerShell em quest\u00e3o foi projetado com uma finalidade muito espec\u00edfica: desativar o SMBv1 em ambientes Windows. Ele funciona usando uma sequ\u00eancia de cmdlets integrados do PowerShell e manipula\u00e7\u00f5es do Registro para garantir que o SMBv1 seja completamente desativado. O script pode ser executado em um ambiente Windows 10 ou Windows Server 2016 ou posterior, o que o torna altamente vers\u00e1til e valioso para qualquer sistema Windows moderno.<\/p>\n<h2>O roteiro: Desativar SMBv1<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Disables SMB v1\r\n.DESCRIPTION\r\n    Disables SMB v1 via Get-WindowsOptionalFeature, Set-SmbServerConfiguration, or Registry\r\n.EXAMPLE\r\n    No parameters needed.\r\n.EXAMPLE\r\n    PS C:&gt; Disable-SMBv1.ps1\r\n    No parameters 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\r\n[CmdletBinding()]\r\nparam ()\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        # 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 Continue | 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 Continue | 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    $Disable = 0\r\n    # $Enable = 1 # Not Used\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    # Try using Get-WindowsOptionalFeature first\r\n    if (-not $(Get-Command -Name \"Get-WindowsOptionalFeature\").Name -like \"Get-WindowsOptionalFeature\") {\r\n        Write-Host \"Get-WindowsOptionalFeature command not found. Continuing.\"\r\n    }\r\n    else {\r\n        if ((Get-WindowsOptionalFeature -Online -FeatureName smb1protocol -ErrorAction SilentlyContinue).State -notlike \"Disabled\") {\r\n            # Disables smb1protocol feature\r\n            try {\r\n                Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol\r\n                # Disabled SMB1, exit\r\n                exit 0\r\n            }\r\n            catch {\r\n                Write-Host \"smb1protocol feature not found. Continuing.\"\r\n            }\r\n        }\r\n    }\r\n\r\n    if (-not $(Get-Command -Name \"Get-SmbServerConfiguration\").Name -like \"Get-SmbServerConfiguration\") {\r\n        Write-Host \"Get-SmbServerConfiguration command not found. Continuing.\"\r\n        $Path = \"HKLM:SYSTEMCurrentControlSetServicesLanmanServerParameters\"\r\n        $Name = \"SMB1\"\r\n        # https:\/\/docs.microsoft.com\/en-us\/windows-server\/storage\/file-server\/troubleshoot\/detect-enable-and-disable-smbv1-v2-v3#registry-editor\r\n        # Sets SMB1 to 0\r\n        Set-ItemProp -Path $Path -Name $Name -Value $Disable\r\n    }\r\n    if ((Get-SmbServerConfiguration).EnableSMB1Protocol) {\r\n        try {\r\n            Set-SmbServerConfiguration -EnableSMB1Protocol $false            \r\n        }\r\n        catch {\r\n            Write-Host \"Failed to disable SMBv1.\"\r\n            exit 1\r\n        }\r\n    }\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Preocupa\u00e7\u00f5es com a seguran\u00e7a em torno do SMBv1<\/h2>\n<p>O SMBv1 \u00e9 conhecido por suas defici\u00eancias de seguran\u00e7a. Ele tem sido um alvo frequente de v\u00e1rios tipos de ataques, ransomware e viola\u00e7\u00f5es de dados. Ter o SMBv1 ativado \u00e9 como deixar a porta da frente aberta; voc\u00ea est\u00e1 simplesmente convidando problemas. Esse script do PowerShell alivia esse problema de forma eficaz, desativando o SMBv1.<\/p>\n<h2>Tempo e efici\u00eancia<\/h2>\n<p>A desativa\u00e7\u00e3o manual do SMBv1 pode ser uma tarefa demorada, especialmente em ambientes de rede de grande escala. Esse script automatiza o processo, economizando tempo e esfor\u00e7o valiosos. Para os MSPs que gerenciam redes de v\u00e1rios clientes, essa ferramenta \u00e9 uma d\u00e1diva de Deus.<\/p>\n<h2>Abordagem abrangente<\/h2>\n<p>O script tenta desativar o SMBv1 por meio de v\u00e1rios caminhos, incluindo o cmdlet Get-WindowsOptionalFeature, o cmdlet Set-SmbServerConfiguration e edi\u00e7\u00f5es diretas no Registro. Isso garante que o protocolo seja desativado, mesmo que um dos m\u00e9todos falhe ou n\u00e3o esteja dispon\u00edvel no sistema em quest\u00e3o.<\/p>\n<h2>Como usar o script Disable SMBv1<\/h2>\n<p>A execu\u00e7\u00e3o do script \u00e9 simples. Aqui est\u00e1 um guia r\u00e1pido:<\/p>\n<ol>\n<li>Salve o script em um arquivo chamado Disable-SMBv1.ps1.<\/li>\n<li>Abra o PowerShell como administrador.<\/li>\n<li>Navegue at\u00e9 a pasta onde voc\u00ea salvou o script.<\/li>\n<li>Execute o script digitando PS C:&gt;.Disable-SMBv1.ps1 e pressionando Enter.<\/li>\n<\/ol>\n<p>Certifique-se de que voc\u00ea tenha privil\u00e9gios de administrador ou o script ser\u00e1 encerrado, garantindo que voc\u00ea n\u00e3o fa\u00e7a altera\u00e7\u00f5es acidentais que n\u00e3o deveria.<\/p>\n<h2>Quem precisa desse roteiro?<\/h2>\n<ul>\n<li><strong>Profissionais de TI:<\/strong> Se voc\u00ea \u00e9 respons\u00e1vel pela manuten\u00e7\u00e3o de uma rede corporativa ou mesmo de uma rede de menor escala, esse script deve fazer parte de seu kit de ferramentas. Com isso, voc\u00ea pode automatizar o processo de desativa\u00e7\u00e3o do SMBv1 em v\u00e1rios sistemas de uma s\u00f3 vez.<\/li>\n<li><strong>Provedores de servi\u00e7os gerenciados (MSPs):<\/strong> Para quem gerencia redes de v\u00e1rios clientes, a capacidade de desativar rapidamente protocolos vulner\u00e1veis, como o SMBv1, pode adicionar uma camada extra de seguran\u00e7a, tornando seu servi\u00e7o mais valioso para os clientes.<\/li>\n<\/ul>\n<h2>Integra\u00e7\u00e3o do script com o NinjaOne<\/h2>\n<p>Para profissionais de TI e provedores de servi\u00e7os gerenciados (MSPs) que confiam no NinjaOne como sua <a href=\"https:\/\/www.ninjaone.com\/pt-br\/rmm\/\">solu\u00e7\u00e3o de monitoramento e gerenciamento remoto<\/a>, a incorpora\u00e7\u00e3o desse script em seus protocolos regulares de manuten\u00e7\u00e3o ou seguran\u00e7a pode acrescentar outra camada de robustez \u00e0s suas opera\u00e7\u00f5es.<\/p>\n<h3>Execu\u00e7\u00e3o programada<\/h3>\n<p>Voc\u00ea pode programar a execu\u00e7\u00e3o do script do PowerShell por meio do Scripting Engine do NinjaOne. Ao fazer isso, voc\u00ea garante que o SMBv1 seja automaticamente desativado em todos os novos sistemas adicionados \u00e0 rede ou em todos os sistemas que forem reinicializados, mantendo assim uma postura de seguran\u00e7a uniforme.<\/p>\n<h3>Monitoramento e alertas<\/h3>\n<p>Com os recursos de alerta do NinjaOne, voc\u00ea pode criar alertas personalizados que o notificam quando o script for executado com \u00eaxito ou se encontrar algum problema. Isso lhe d\u00e1 feedback em tempo real, permitindo que voc\u00ea intervenha conforme necess\u00e1rio.<\/p>\n<h3>Implementa\u00e7\u00e3o remota<\/h3>\n<p>O Disable SMBv1 Script pode ser implantado remotamente em v\u00e1rios sistemas por meio do NinjaOne. Isso \u00e9 particularmente \u00fatil para MSPs que gerenciam uma grande variedade de redes. Com apenas alguns cliques, \u00e9 poss\u00edvel aplicar uma pol\u00edtica de seguran\u00e7a essencial em todos os endpoints gerenciados.<\/p>\n<h3>Relat\u00f3rios de conformidade<\/h3>\n<p>Para os requisitos de conformidade, como GDPR ou HIPAA, em que a desativa\u00e7\u00e3o de protocolos desatualizados e vulner\u00e1veis pode ser obrigat\u00f3ria, a execu\u00e7\u00e3o desse script por meio do NinjaOne pode lhe oferecer uma maneira perfeita de provar que as medidas de seguran\u00e7a adequadas est\u00e3o em vigor. Os recursos de relat\u00f3rio do NinjaOne podem ajud\u00e1-lo a gerar relat\u00f3rios abrangentes para trilhas de auditoria.<\/p>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>Desativar o SMBv1 deve ser algo \u00f3bvio para qualquer organiza\u00e7\u00e3o que leve a seguran\u00e7a da rede a s\u00e9rio. Esse script do PowerShell oferece um m\u00e9todo confi\u00e1vel, eficiente e abrangente para fazer exatamente isso. Dada a necessidade cr\u00edtica de protocolos de seguran\u00e7a refor\u00e7ados no atual cen\u00e1rio de TI empresarial, a ado\u00e7\u00e3o desse script deve ser uma prioridade m\u00e1xima.<\/p>\n","protected":false},"author":35,"featured_media":142090,"parent":0,"menu_order":0,"comment_status":"open","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-808025","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\/808025","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=808025"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/142090"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=808025"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=808025"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=808025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}