You are correct, the problem wasn't with any of the code, it was newbie user error

I was copying the code from notepad++ to powershell window instead of running the actual .ps1 script file from the folder


Thanks Steffen and penpen for your assistance