r/PowerShell • u/jack_ery21 • Dec 09 '25
Question Set DNS through powershell
Hey guys So I have an odd problem, I’m sure anyone else who also uses FortiClient may also have this too.
When FortiClient disconnects, on rare occasions it doesn’t remove the internal dns on the wifi adapter so the laptop becomes useless and needs a tech to physically go fix it by setting the dns back to automatic.
We use NinjaOne and I want to make a script that will be accessible by the end user using the SysTray feature, they can run pre-made automations.
Doing some testing today and I was looking at using Set-DNSClientServerAddress, but wasn’t having much luck.
Full command I used was Set-DnsClientServerAddress -InterfaceIndex 14 -ResetServerAddresses
This said it worked, but the settings were still there. Am I missing something?
Interface index was correct, checked that.
Device is Windows 11. FortiClient VPN only 7.4.0 (has been happening since V6, so not version relevant)
Thanks
View all comments
Show parent comment
1
u/dodexahedron Dec 11 '25
Why?
Pushing internal DNS servers is extremely common for VPN clients, so you can actually resolve internal resources that you need.