I killed all of my powershell sessions, Ran the following command:
Disconnect-Viserver -Server * -Force -Confirm:$false
Then ran the script, and I am now getting this error on the last line:
Exception calling "CreateObjectScheduledTask" with "2" argument(s): "A specified
parameter was not correct: "