Thanks for the reply.
I am able to run the script on the guest OS with Invoke-Expression $script command.
Also, I am able to login to the console of the guest-OS (Win 7 Ultimate) using an account (Admin).
However, when I try to execute the following, I get the error "Failed to authenticate with the guest operating system using the supplied credentials."
Invoke-VMScript -ScriptText $script -VM MyVM -GuestUser Admin -GuestPassword pass$123