One simple builtin solution is to use the New-VICredentialStoreItem cmdlet.
You can use the Get-VICredentialStoreItem cmdlet to retrieve user/password information.
This can be used for credentials that have nothing to do with vSphere as well.
Use the Server as a tag for the credentials.
The credentials can only be decrypted by the same user and on the same station where the encryption was done.
Note, since this is based on a Windows encryption/decryption API, it will not work on PowerShell Core.
that looks good so far..
the problem is that the Password must be System.String. I have to provide the password in the script or in the cmd. Both would be clear text..
with the readline -asSecurestring command the input is hidden and cant be read.
You can do the following to compare them$encpasswort1 = Read-Host "Please Enter pwd: " -AsSecureString
$encpasswort2 = Read-Host "again" -AsSecureString
$clearpasswort1 = (New-Object pscredential "user",$encpasswort1).GetNetworkCredential().Password
$clearpasswort2 = (New-Object pscredential "user",$encpasswort2).GetNetworkCredential().Password
$clearpasswort1 -eq $clearpasswort2