I've got this basic PowerShell script aimed at moving files from one folder to another. I've been running it in PowerShell ISE with administrative privileges since I need elevated access for later parts of the script. However, there's a hiccup: when I press F5 to run the script, I get an error stating 'MoveThem: The term 'MoveThem' is not recognized as the name of a cmdlet, function, script file, or operable program.' It's odd because after that, if I hit F5 again, it works fine. I've tried adding pauses and even a 'While Get Command' check, but nothing seems to help. Any advice?
2 Answers
One common mistake is calling the function before it's defined. Make sure your function declaration is at the top of the script, like this:
Function MoveThem{...}
MoveThem
That should fix the error you're seeing!
You should really post your entire script to get better help. Also, it’s worth noting that PowerShell ISE isn't actively supported anymore, so that might be part of the issue. Just a thought!

OMG, that was it. fml Thanks!