I ran into the exact same issue. Who did you log into the workstation as when it worked? A domain administrator someone with permission to move a object? That was what our issue was the script needed to be run as an administrator and more often than not the machine was being logged into as a normal user. We fixed it by creating a shortcut that “ran as” an appropriate user.
Now we use the same script to introduce new machines from the test ou. The script changes the local admin password, installs software packages, deploys AV configure services and copies over certain files and settings. Then it moves the machine out of the test ou!
A very gratifying feeling after I got it working!