I have a powershell script that manually sets my dns. I need it to run whenever the network interface comes up or changes.
For example, when I go on and off the docking station (that has wired internet), I need the script to fire.
It needs to run as administrator.
What is the path to do this? (a job that runs every couple of minutes seems.... not elegant?)
Dead Ends Found So Far
It has been suggested to follow the steps here, How to Launch Command on Network Connection. This does not solve for the following reason:
Looking at Windows 10, 20H2 (what is running here), I see that:
Event ID: 10000
Is logged three times when the system boots up.
I don't want my script to run three times (certainly not on top of each other, which it appears would happen), AND for my script it is important that DHCP has come up and the route table has settled down.
My script needs to run whenever networking comes up or there is a change in the Active network interface (or the number of interfaces that are Up).
How to achieve that?
Current Solve Direction
Having a scheduled task hang from an event looks like a great solve direction, however so far I cannot identify a clean event to hang the event on. (I have dug through a ton of the event log, without finding any clean events to use. (Not even much that is unclean.) Hints welcome!)