I'm afraid you are mixing two things here.
- Use the GuestUser and GuestPassword parameters
- Use the GuestCRedential parameter
The GuestCRedential parameter can be easily obtained like this
$cred = Get-Credential
Invoke-VMScript .... -GuestCredential $cred ....
When you run the Invoke-VMScript cmdlet against vSphere earlier than 4.0, you have to use the HostUser/HostPassword or HostCredential parameter.
Since vSphere 4.0 that is not required anymore.
The sample code you mention is older, or is written to run against most vSphere versions.