PowerShell script error: the string is missing the terminator:
It's similar with this question.
When you copy cmdlets from Web, maybe there are some special characters. I suggest you could copy the cmdlets to Notepad then copy to PowerShell.
It's helpful to use cat filename.ps1 in the terminal you can see determine which characters are bad, it's not obvious in the editor.