Couldn’t understand how you executed above code. You should be executing a .ps1 file. When PowerShell is something matters to you task in hand, you should definitely take some time and understand some basics.
Note: Please format code when you post next time. You can do the same for your previous reply.