How to create and use CredentialStoreItem

How to create and use CredentialStoreItem

$VIServer = "myserver"
$user = "mydomain\myuser"
$password = "**********"
$FilePath = "c:\users\myuser\desktop\mycred.xml"

#Creates a new file with your credentials
New-VICredentialStoreItem -Host $VIServer -User $user -Password $password -File $FilePath

#Get your credentials from file and keeps on a new variable
$cred = Get-VICredentialStoreItem -Host $VIServer -File $FilePath

#Connects using the VICredentialStoreItem
Connect-VIServer -User $cred.User -Password $cred.Password -Server $VIServer

#To remove the credential File
Remove-Item -Path $FilePath -Force

Version history
Revision #:
1 of 1
Last update:
‎04-24-2014 09:13 AM
Updated by: