I wouldn't add all of that validation inside of the script itself. The script is meant to apply settings. I would definitely pull all of that out into a set of Pester tests. Putting some validation checks in your scripts is great but it sounds like you might be overdoing it. Adding more code adds more complexity and it's important to keep scripts as simple as possible. If those tests are separated out into a Pester test you have the opportunity to do unit testing as well as some of the integration testing you're talking about.
It turns out that Windows 7 and 8.1 (and Windows Vista, but that's out of support anyway) have a similar kind of bug. They can be taken advantage of in the same kind of way: certain bad filenames make the system lock up or occasionally crash with a blue screen of death, and malicious webpages can embed those filenames by using them as image sources. If you visit such a page (in any browser), your PC will hang shortly after and possibly crash outright.