And BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Yes, I am looking to create a script where it does the following: 1) Continuously check for an internet connection (Even if the computer is turned off or restarted). 2) Sends a notification via email 3) Disables Ethernet and Wi-Fi connection. 4) restarts the script again.
OK. And what is your question? You should ask a specific question about a particular piece of you code you wrote yourself and you have an issue with.
Please keep in mind - this forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.
We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.
Please do not post images of code or error messages. Instead post the plain text and format it as code.
There are several issues with your code. I’d recommend to do a big step back and start with learning the very basics of PowerShell first. This will save you from a lot of wasted time and frustrations.
You should ALWAYS read the complete help including the examples for the cmdlets you’re about to use to learn how to use them
Amlost everything. Test-NetConnection does not have a parameter -Quiet. The syntax for your if statement is wrong. You should consider adding a pause to decrease the load you put on your computer for this task.