Yes: as @SLW210 says, it seems to work well.
On the other hand:
Have you considered having the script written only if it does not already exist in the expected directory, and keeping PowerShell running from the initial load?
This would make the dialog box load faster on subsequent calls.
In this regard, the script check/creation could be done when the code is loaded. This would also improve the speed of the first execution slightly.