Comment

best option is to use $host.ui.PromptForCredential() to get both the username and password, the result of which Connect-VIServer can take via its -Credential option