It just occurred to me that a very useful feature of PowerCLI never got the introduction it deserves. The feature is the Credential Store and as the name suggests its job is to store credentials. As a result:
- Credentials are kept securely (no need to hard code passwords along with scripts)
- You type less (no need to specify user and password to Connect-VIServer)
So, how does it work in practice?
Say I connect to my VC like this:
Connect-VIServer 192.168.10.10 –User Andrey –Password “my favorite password”
To use the credential store, I do the following:
New-VICredentialStoreItem -Host 192.168.10.10 -User "Andrey" -Password "my favorite password"
Now I can type just:
Connect-VIServer 192.168.10.10
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.
Andrey Anastasov,
PowerCLI Architect