I want to create a powershell script that alerts a user on a device that they have lost network connectivity.
- Can i set an alert through WMI ?
- Would it have to be a service running all the time and alert if network connections goes ?
- Should i use a workflow so the script continues or just loop ?
Got a few thoughts but not sure how to go forward with it.
WMI isn’t an “alerting” system. You could potentially have WMI trigger an event that notified your own code, sure. And I’d strongly recommend that it be a service, yes - services are designed to run in the background. But that means not writing it in PowerShell, as PowerShell is not designed to run as a continuous service. And no, Workflow isn’t designed for this, either.
I’m a little confused, though, because since at least Windows 7, there’s been a task bar alert when this happens, right? I’m guessing your users just aren’t noticing that.
In any event, I don’t personally feel PowerShell is a good solution for this. It’s going to be a kludge at best, and an ugly kludge at that. At worst, it’ll end up being a memory hog (remember, PowerShell fires up a good portion of .NET, which is a little lazy about memory).
Thanks Don. The users are field engineers and it was to advise them. Your right, the notification is a bit small for them as they are on tablets running Windows 8.1.
I was just thinking of a script that would pop up a gui window when the connection was lost.
Don is right but if you have to do it here is an option.
You could use a powershell script to display a message but let task scheduler look for the lost network connect event Windows Task Scheduler: Trigger an Event When Internet Connects or Disconnects
That looks useful Jonathan, thanks. Just a solution to help some engineers. Could I script the creation of the schedule to setup on mass ?