Advertisement
crexin

Disable SMBv1 with PowerShell

May 15th, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Disable SMBv1 protocol
  3. #>
  4.  
  5. #Command to disable SMBv1
  6. # Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
  7.  
  8. <# Commands below are grouped by operating system and first disable the SMBV1 protocol and then
  9. verify that it's set by verifying it's set to false
  10.  
  11. Also note that the dnshostname might be blank in some instances, so can either select the entire
  12. object or select the name from the Get-adcomputer command
  13.  
  14. Add Filters as needed to the get-adcomputer command
  15. #>
  16.  
  17. # for Server 2012 and Server 2012R2
  18. get-adcomputer -Filter * -Property *|
  19. Where-object {$_.OperatingSystem -like "*2012*"}|
  20. select DNSHostname|
  21. foreach-object{Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force}
  22.  
  23.  
  24. get-adcomputer -Filter * -Property *|
  25. Where-object {$_.OperatingSystem -like "*2012*"}|
  26. select DNSHostname|foreach-object{(get-smbserverconfiguration).EnableSMB1Protocol}
  27.  
  28. # Server 2008 and 2008R2
  29. get-adcomputer -Filter * -Property *|
  30. Where-object {$_.OperatingSystem -like "*2008*"}|
  31. select DNSHostname|
  32. foreach-object{Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force}
  33.  
  34.  
  35. get-adcomputer -Filter * -Property *|
  36. Where-object {$_.OperatingSystem -like "*2008*"}|
  37. select DNSHostname|foreach-object{(get-smbserverconfiguration).EnableSMB1Protocol}
  38.  
  39.  
  40. # Non-Server Operating Systems
  41. get-adcomputer -Filter * -Property *|
  42. Where-object {$_.OperatingSystem -notlike "*server*"}|
  43. select DNSHostname|
  44. foreach-object{Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force}
  45.  
  46.  
  47. get-adcomputer -Filter * -Property *|
  48. Where-object {$_.OperatingSystem -notlike "*server*"}|
  49. select DNSHostname|foreach-object{(get-smbserverconfiguration).EnableSMB1Protocol}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement