What It Does
This script changes nothing until you set DryRun=false and Approve=disable-smb1. Before that it prints what it would do. It also refuses to make more than 25 changes in one run unless you raise MaxChanges.
With a positive AuditDays and AllowClientUse off, the script checks event 3000 in the SMB1 access audit log. It skips the change if clients were seen using SMB1 and lists them, or skips if server auditing is off. Setting AuditDays to zero or turning on AllowClientUse bypasses the check.
Then it saves the LanmanServer registry key to the MSPOutpost backup folder, sets the SMB server's EnableSMB1Protocol to False, which takes effect at once, and disables the SMB1Protocol optional feature, or its client and server parts when only those are enabled, with no restart.
Disabling the feature also turns off its SMB1 client component after the next restart. The script leaves the restart to you and reports when one is needed. Drive mappings and scans to old devices that only speak SMB1 stop working after that restart. SMB2, SMB3, signing, firewall rules and shares are not changed.
Before You Run It
- Turn on SMB1 auditing with Set-SmbServerConfiguration -AuditSmb1Access $true and let it run a few weeks. Use test-smb1 to read who still connects.
- List the old scanners, copiers, NAS boxes and software that may need SMB1 and sort them out first.
- Run it once as a dry run and read the list, then run it for real.
- Plan the restart that removes the SMB1 client, and warn the user.
Type and Risk
- Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
- Risk: High. It is a dry run unless you set both DryRun=false and Approve=disable-smb1, and it stops before making more than 25 changes in one run unless you raise MaxChanges. Run it once as a dry run and read the list first.
- What it changes: Sets EnableSMB1Protocol to False; disables the SMB1Protocol optional feature (no restart); saves a registry backup first.
- Restart: It never restarts the machine itself. When a restart is needed to finish, the answer says so.
- Typical run: Under 1 minute.
- Example answer: "SMB1 disabled: server setting off, feature SMB1Protocol disabled; restart needed to remove the SMB1 client"
- Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- AuditDays: How many days of the SMB1 access audit log to read before acting. Whole number 0 to 365; 0 skips the check. Default 30.
- AllowClientUse: true to disable SMB1 even when the audit log shows clients still using it. Default false.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.