Disabling SMBv1
PowerShell Script to disable SMBv1
# Disable SMBv1 Protocol Components
# Run as Administrator
Write-Host "Disabling SMBv1 components..." -ForegroundColor Yellow
# Disable SMBv1 Server
Try {
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Write-Host "SMBv1 Server disabled"
}
Catch {
Write-Host "SMBv1 Server configuration not available"
}
# Disable SMBv1 Client
Try {
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol -NoRestart
Write-Host "SMBv1 Client feature disabled"
}
Catch {
Write-Host "SMBv1 Client feature not present"
}
# Disable SMBv1 using registry (fallback)
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name SMB1 -Value 0 -Type DWORD
Write-Host "Registry SMBv1 server setting disabled"
# Disable SMBv1 Client Driver
Try {
Set-Service -Name "mrxsmb10" -StartupType Disabled -ErrorAction Stop
Stop-Service -Name "mrxsmb10" -Force -ErrorAction SilentlyContinue
Write-Host "SMBv1 client driver disabled"
}
Catch {
Write-Host "SMBv1 client driver not found"
}
Write-Host ""
Write-Host "SMBv1 has been disabled. A reboot is recommended." -ForegroundColor Green