Bekijk een demo×
×

Zie NinjaOne in actie!

Door dit formulier in te dienen geef ik aan akkoord te gaan met het privacybeleid van NinjaOne.

Hoe SMBv1 Uitschakelen met PowerShell

Het Server Message Block Protocol (SMB) bestaat al geruime tijd en dient als ruggengraat voor het delen van bestanden en verschillende andere netwerkactiviteiten. De vroegste versie, SMBv1, wordt nu echter gezien als een risico vanwege een groot aantal zwakke plekken in de beveiliging. Als u een IT-professional of een Managed Service Provider (MSP) bent, moet netwerkbeveiliging uw grootste zorg zijn. Dus, hoe schakelt u SMBv1 effectief uit?

Wat Doet het Script?

Het PowerShell-script is ontworpen met een heel specifiek doel: SMBv1 uitschakelen in Windows-omgevingen. Het werkt door gebruik te maken van een reeks ingebouwde PowerShell cmdlets en registermanipulaties om ervoor te zorgen dat SMBv1 volledig wordt uitgeschakeld. Het script kan worden uitgevoerd in een Windows 10 of Windows Server 2016 omgeving of later, waardoor het zeer veelzijdig en waardevol is voor elk modern Windows systeem.

Het script: SMBv1 Uitschakelen

#Requires -Version 5.1

<#
.SYNOPSIS
    Disables SMB v1
.DESCRIPTION
    Disables SMB v1 via Get-WindowsOptionalFeature, Set-SmbServerConfiguration, or Registry
.EXAMPLE
    No parameters needed.
.EXAMPLE
    PS C:> Disable-SMBv1.ps1
    No parameters needed.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10, Windows Server 2016
    Release Notes:
    Initial Release
By 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.
    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. 
    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. 
    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. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, 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. 
    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. 
    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. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>

[CmdletBinding()]
param ()

begin {
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
        { Write-Output $true }
        else
        { Write-Output $false }
    }
    function Set-ItemProp {
        param (
            $Path,
            $Name,
            $Value,
            [ValidateSet("DWord", "QWord", "String", "ExpandedString", "Binary", "MultiString", "Unknown")]
            $PropertyType = "DWord"
        )
        # Do not output errors and continue
        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
        if (-not $(Test-Path -Path $Path)) {
            # Check if path does not exist and create the path
            New-Item -Path $Path -Force | Out-Null
        }
        if ((Get-ItemProperty -Path $Path -Name $Name)) {
            # Update property and print out what it was changed from and changed to
            $CurrentValue = Get-ItemProperty -Path $Path -Name $Name
            try {
                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Continue | Out-Null
            }
            catch {
                Write-Error $_
            }
            Write-Host "$Path$Name changed from $CurrentValue to $(Get-ItemProperty -Path $Path -Name $Name)"
        }
        else {
            # Create property with value
            try {
                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Continue | Out-Null
            }
            catch {
                Write-Error $_
            }
            Write-Host "Set $Path$Name to $(Get-ItemProperty -Path $Path -Name $Name)"
        }
        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue
    }
    $Disable = 0
    # $Enable = 1 # Not Used
}
process {
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges."
        exit 1
    }
    
    # Try using Get-WindowsOptionalFeature first
    if (-not $(Get-Command -Name "Get-WindowsOptionalFeature").Name -like "Get-WindowsOptionalFeature") {
        Write-Host "Get-WindowsOptionalFeature command not found. Continuing."
    }
    else {
        if ((Get-WindowsOptionalFeature -Online -FeatureName smb1protocol -ErrorAction SilentlyContinue).State -notlike "Disabled") {
            # Disables smb1protocol feature
            try {
                Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol
                # Disabled SMB1, exit
                exit 0
            }
            catch {
                Write-Host "smb1protocol feature not found. Continuing."
            }
        }
    }

    if (-not $(Get-Command -Name "Get-SmbServerConfiguration").Name -like "Get-SmbServerConfiguration") {
        Write-Host "Get-SmbServerConfiguration command not found. Continuing."
        $Path = "HKLM:SYSTEMCurrentControlSetServicesLanmanServerParameters"
        $Name = "SMB1"
        # https://docs.microsoft.com/en-us/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3#registry-editor
        # Sets SMB1 to 0
        Set-ItemProp -Path $Path -Name $Name -Value $Disable
    }
    if ((Get-SmbServerConfiguration).EnableSMB1Protocol) {
        try {
            Set-SmbServerConfiguration -EnableSMB1Protocol $false            
        }
        catch {
            Write-Host "Failed to disable SMBv1."
            exit 1
        }
    }
}
end {}

 

Toegang tot meer dan 300 scripts in de NinjaOne Dojo

Toegang Krijgen

Beveiligingsproblemen Rondom SMBv1

SMBv1 is berucht om zijn tekortkomingen op het gebied van beveiliging. Het is een veelvoorkomend doelwit geweest van verschillende soorten aanvallen, ransomware en datalekken. SMBv1 inschakelen is net zoiets als uw voordeur open laten staan; u nodigt gewoon problemen uit. Dit PowerShell-script verhelpt dit probleem effectief door SMBv1 uit te schakelen.

Tijd en Efficiëntie

SMBv1 handmatig uitschakelen kan een tijdrovende klus zijn, vooral in grootschalige netwerkomgevingen. Dit script automatiseert het proces en bespaart waardevolle tijd en moeite. Voor MSP’s die netwerken van meerdere klanten beheren, is deze tool een uitkomst.

Uitgebreide Aanpak

Het script probeert SMBv1 op meerdere manieren uit te schakelen, waaronder het cmdlet Get-WindowsOptionalFeature, het cmdlet Set-SmbServerConfiguration en directe registerbewerkingen. Dit zorgt ervoor dat het protocol wordt uitgeschakeld, zelfs als een van de methoden faalt of niet beschikbaar is op het systeem in kwestie.

Hoe het Script SMBv1 Uitschakelen Gebruiken

Het uitvoeren van het script is eenvoudig. Hier volgt een korte handleiding:

  1. Sla het script op in een bestand met de naam Disable-SMBv1.ps1.
  2. Open PowerShell als Administrator.
  3. Navigeer naar de map waar u het script hebt opgeslagen.
  4. Voer het script uit door PS C:>.Disable-SMBv1.ps1 te typen en op Enter te drukken.

Zorg ervoor dat u Administrator rechten hebt, anders wordt het script afgesloten, zodat u niet per ongeluk wijzigingen aanbrengt die u niet zou moeten doen.

Wie heeft dit script nodig?

  • IT-professionals: Als u verantwoordelijk bent voor het onderhoud van een bedrijfsnetwerk of zelfs een kleinschalig netwerk, dan zou dit script deel moeten uitmaken van uw gereedschapskist. Hiermee kunt u het uitschakelen van SMBv1 op meerdere systemen in één keer automatiseren.
  • Managed Service Providers (MSP’s): Voor degenen die netwerken van meerdere klanten beheren, kan de mogelijkheid om snel kwetsbare protocollen zoals SMBv1 uit te schakelen een extra beveiligingslaag toevoegen, waardoor uw service waardevoller wordt voor uw klanten.

Het Script Integreren met NinjaOne

Voor IT-professionals en Managed Service Providers (MSP’s) die vertrouwen op NinjaOne als hun oplossing voor Remote Monitoring en Management, kan het opnemen van dit script in je reguliere onderhouds- of beveiligingsprotocollen een extra laag van robuustheid toevoegen aan uw activiteiten.

Geplande uitvoering

U kunt de uitvoering van het PowerShell-script plannen via de Scripting Engine van NinjaOne. Door dit te doen, zorgt u ervoor dat SMBv1 automatisch wordt uitgeschakeld op alle nieuwe systemen die worden toegevoegd aan het netwerk of systemen die opnieuw worden geïnitialiseerd, waardoor een uniforme beveiligingshouding wordt gehandhaafd.

Bewaking en Waarschuwingen

Met de waarschuwingsfuncties van NinjaOne kunt u aangepaste waarschuwingen maken die u laten weten wanneer het script met succes is uitgevoerd of wanneer er problemen optreden. Dit geeft u real-time feedback, zodat u kunt ingrijpen als dat nodig is.

Remote Deployment

Het Disable SMBv1 Script kan op afstand op meerdere systemen worden geïnstalleerd via NinjaOne. Dit is vooral handig voor MSP’s die een groot aantal netwerken beheren. Met een paar klikken kunt u een cruciaal beveiligingsbeleid afdwingen op al uw beheerde endpoints.

Rapportage over naleving

Voor compliance-eisen zoals GDPR of HIPAA, waar het uitschakelen van verouderde en kwetsbare protocollen verplicht kan zijn, kan het uitvoeren van dit script via NinjaOne je een naadloze manier bieden om aan te tonen dat de juiste beveiligingsmaatregelen zijn getroffen. Met de rapportagefuncties van NinjaOne kunt u uitgebreide rapporten voor audit trails genereren.

Slotbeschouwingen:

SMBv1 uitschakelen zou een no-brainer moeten zijn voor elke organisatie die netwerkbeveiliging serieus neemt. Dit PowerShell-script biedt een betrouwbare, efficiënte en uitgebreide methode om precies dat te doen. Gezien de kritieke behoefte aan betere beveiligingsprotocollen in het huidige IT-landschap van ondernemingen, zou het aannemen van dit script een topprioriteit moeten zijn.

Volgende stappen

Het opbouwen van een efficiënt en effectief IT-team vereist een gecentraliseerde oplossing die fungeert als uw kerndienstleveringstool. NinjaOne stelt IT-teams in staat om al hun apparaten te monitoren, beheren, beveiligen en ondersteunen, waar ze ook zijn, zonder de noodzaak van complexe on-premises infrastructuur.

Leer meer over NinjaOne Endpoint Management, bekijk een live rondleiding, of start uw gratis trial van het NinjaOne-platform

Categorieën:

Dit vindt u misschien ook leuk

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • 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.
  • 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.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, 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.
  • 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.
  • 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.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).