PowerCLI is one of the best tools in the Market for those who have a good understanding of scripting and also a good tool which you should be knowing if you are working with VMware Products. Today i will be showing you a way to make PowerCLI for Easy Login to vCenter.
Here we are going to make use of Credential Store feature to make login to vCenter Easier.
Step 1:
Open PowerShell.
Step 2:
For the First time you will have to login to vCenter using your Username and Password as showing below:
Type: Connect-VIServer –User <administrator@vsphere.local> –Password <“@Test1992”>
Command Output:
PS C:\Users\Administrator> Connect-VIServer vcsa.ashu.com –User administrator@vsphere.local –Password “@Asd1992”
Name Port User
---- ---- ----
vcsa.ashu.com 443 VSPHERE.LOCAL\Administrator
Step 3:
Now you can save your frequently user credentials in the credential store of the vCenter using:
New-VICredentialStoreItem -Host -User <“administrator@vsphere.local”> -Password <“@Test1992”>
PS C:\Users\Administrator> New-VICredentialStoreItem -Host vcsa.ashu.com -User "administrator@vsphere.local" -Password "@Asd1992"
Host User File
---- ---- ----
vcsa.ashu.com administrator@vsp...
Now once this is done you can login to vCenter Simply using below:
PS C:\Users\Administrator> Connect-VIServer vcsa.ashu.com
Name Port User
---- ---- ----
vcsa.ashu.com 443 VSPHERE.LOCAL\Administrator
This will make life of an IT Administrator easier and you can use the same credentials in any scripts as well without passing your password. Also you don’t need to worry about the password as its hashed and saved securely within the system.
You can also use this to create a VMware credential store XML file that is used by 3rd party plugins to authenticate with vCenter Server using credentials that are already stored.
- Connect to vCenter Server using the command:
Connect-VIServer -Server
Where is the IP address or DNS name of vCenter Server or the ESX host.
- When prompted, enter your user name and password to authenticate with the server.
- Use this command to create the credential store XML file:
New-VICredentialStoreItem -Host -User -Password -File
- Mention the location of the XML file created in the above step when prompted during the installation of third party plugins.
When I don’t specify user and/or password, Connect-VIServer checks the credential store, finds my newly stored credential and uses it.
By default the credential store file is stored under the user profile directory. It is encrypted. If I got you interested, check “help *VICredentialStoreItem” for details.