WIN-020 · Script
Network Stack Reset and DNS Flush
Checks basic network health and can flush DNS, renew DHCP leases, and reset Winsock and TCP/IP.
What it does
Report mode (default) lists the active network adapters with their IP, gateway, DNS servers and DHCP state, then tests the default gateway, DNS name resolution and an HTTPS connection to -TestHost. Nothing is changed.
Flush mode is the light fix and does not need a restart:
- clears the DNS client cache
- renews the DHCP lease on DHCP adapters (optionally releasing it first with -ReleaseFirst)
- re-registers the device in DNS
FullReset mode does everything in Flush, then resets the Winsock catalog and the IPv4 and IPv6 TCP/IP settings with netsh. A restart is needed to finish a full reset; the script restarts the device only if -Reboot is set.
Important: a TCP/IP reset can remove static IP addresses and some VPN or security software settings. Before a full reset the script saves every adapter's IP configuration to a CSV in -ReportDir so static settings can be re-entered. Renewing or releasing DHCP briefly drops the network connection, which can interrupt a remote session; the RMM agent normally reconnects on its own. Runs silently as SYSTEM. No prompts.
Requirements
Windows PowerShell 5.1+, run as SYSTEM or local admin
How to run it
- Run as: SYSTEM or a local administrator
- Run from: any RMM or MDM, Intune, a Group Policy startup script, a scheduled task, or an elevated PowerShell window
- Script type: PowerShell, 64-bit
- User interaction: none; the script never prompts
- Timeout: 10 minutes (30 for Windows Update installs)
Settings
| Name | What it does | Options | Default |
|---|---|---|---|
| Mode | Report (default), Flush or FullReset. | Report, Flush, FullReset | Report |
| TestHost | Host name used for the DNS and HTTPS tests. Default www.microsoft.com. | www.microsoft.com | |
| ReleaseFirst | In Flush and FullReset, release the DHCP lease before renewing. Off by default. | False | |
| Reboot | FullReset only: restart the device after the reset to finish it. | False | |
| RebootDelaySeconds | Delay before the restart, so the RMM can collect the result. Default 120. | 120 | |
| ReportDir | Folder for the adapter configuration backup. Default C:\ProgramData\Runbookia\Reports | C:\ProgramData\Runbookia\Reports |
Exit codes
- 0 = Network tests passed (after the fix in Flush mode, or reset done in FullReset)
- 1 = DNS lookup or HTTPS test failed (gateway ping is shown but not counted,
- because some gateways block ping)
- 2 = Script error
Testing steps
- Run it first with the mode set to Report on one test device. Nothing is changed in that mode.
- Read the log and confirm the planned changes are what you expect.
- Run your chosen settings on the same test target and confirm the result.
- Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
- Roll out to a small group next, then everyone.
Rollback steps
Flush changes nothing permanent. After a FullReset, restart the device, then re-enter any static IP, DNS or proxy settings from the NetworkConfigBackup CSV saved in the report folder. Reinstall or repair VPN software if it stops working.
Version and change log
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | November 2026 | First release. |