Hello, un petit script simple en PowerShell pour désactiver le protocole SMBv1 sur tous les serveurs Windows de votre parc Active Directory.
Attention toute de même si vous avez des applis, des serveurs d’impressions…etc, qui utilisent cette version…à ne pas tout foutre en l’air 🙂
Dans le scripts vous pouvez exclure par nom de machine.
Le reboot auto est désactivé, il faudra planifier un reboot le soir ou le weekend 🙂
Import-Module ActiveDirectory $Servers = Get-ADComputer -Filter {OperatingSystem -Like 'Windows Server*' -and Name -notlike '*PRINT*' -and Name -notlike 'EX-*' } -Property * | Select-object Name,OperatingSystem,OperatingSystemServicePack $2012 = $Servers | where { $_.OperatingSystem -like "Windows Server 2012 Datacenter"} $2012R2 = $Servers | where { $_.OperatingSystem -like "Windows Server 2012 R2*" } $2016 = $Servers | where { $_.OperatingSystem -like "Windows Server 2016 *" } $2019 = $Servers | where { $_.OperatingSystem -like "Windows Server 2019 *" } ForEach ($Serv in $2012) { Invoke-Command -Computer $Serv.Name -ScriptBlock { Get-SMBServerConfiguration | Select-Object -Property PSComputerName,EnableSMB1Protoco Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 –Force } } ForEach ($SRV in $2012R2) { Invoke-Command -Computer $Serv.Name -ScriptBlock { Get-SMBServerConfiguration | Select-Object -Property PSComputerName,EnableSMB1Protocol Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart } } ForEach ($SRV in $2016) { Invoke-Command -Computer $Serv.Name -ScriptBlock { Get-SMBServerConfiguration | Select-Object -Property PSComputerName,EnableSMB1Protocol Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart } } ForEach ($SRV in $2019) { Invoke-Command -Computer $Serv.Name -ScriptBlock { Get-SMBServerConfiguration | Select-Object -Property PSComputerName,EnableSMB1Protocol Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart } }
- True : SMBv1 activé
- False : désactivé
A bientôt.