Skip to content

Instantly share code, notes, and snippets.

Created June 27, 2017 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/223c0f48541cf272a1263d0d9e60275b to your computer and use it in GitHub Desktop.
Save anonymous/223c0f48541cf272a1263d0d9e60275b to your computer and use it in GitHub Desktop.
Disable SMB v1
$os = [System.Environment]::OSVersion.VersionString
$os = $os -replace '\D+(\d+)','$1'
# windows 10
if($os.ToString().StartsWith("10"))
{
echo "Windows 10"
Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart
}
# windows 8.1
if ($os.ToString().StartsWith("63"))
{
echo "Windows 8.1"
Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart
}
# windows 8
if ($os.ToString().StartsWith("62"))
{
echo "Windows 8"
Set-SmbServerConfiguration -EnableSMB1Protocol $false
sc.exe config lanmanworkstation depend= bowser/mrxsmb20/nsi
sc.exe config mrxsmb10 start= disabled
}
# windows vista
if ($os.ToString().StartsWith("60"))
{
echo "Windows Vista"
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 -Force
sc.exe config lanmanworkstation depend= bowser/mrxsmb20/nsi
sc.exe config mrxsmb10 start= disabled
}
# windows 7
if ($os.ToString().StartsWith("61"))
{
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 -Force
sc.exe config lanmanworkstation depend= bowser/mrxsmb20/nsi
sc.exe config mrxsmb10 start= disabled
}
# windows xp
if ($os.ToString().StartsWith("5"))
{
echo "Windows XP"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment