Reader small image

You're reading from  Learning PowerCLI - Second Edition

Product typeBook
Published inFeb 2017
Publisher
ISBN-139781786468017
Edition2nd Edition
Right arrow
Author (1)
Robert van den Nieuwendijk
Robert van den Nieuwendijk
author image
Robert van den Nieuwendijk

Robert van den Nieuwendijk is an IT veteran from the Netherlands with over thirty years of experience in Information Technology. He holds a bachelor degree in software engineering. After working a few years as a programmer of air traffic control and vessel traffic management systems, he started his own company Van den Nieuwendijk Informatica in 1988. Since then he has worked as a freelance systems administrator of OpenVMS, Windows Server, Linux, and VMware vSphere systems, for Dutch governmental organizations and cloud providers. During winter he is also a ski and snowboard instructor at an indoor ski school. With his background as a programmer, he always tries to make his job easier by writing programs or scripts to perform repeating tasks. In the past, he used the C programming language, OpenVMS DCL, Visual Basic Script and KiXtart to do this. Now, he uses Microsoft PowerShell and VMware PowerCLI for all of his scripting work. Robert is a frequent contributor and moderator at the VMware VMTN Communities. Since 2012 VMware awarded him the vExpert title for his significant contributions to the community and a willingness to share his expertise with others. He has a blog at http://rvdnieuwendijk.com where he writes mainly about VMware PowerCLI, Microsoft PowerShell, and VMware vSphere. If you want to get in touch with Robert, then you can find him on Twitter. His username is @rvdnieuwendijk. Robert is also the author of Learning PowerCLI, Packt Publishing.
Read more about Robert van den Nieuwendijk

Right arrow

Using the credential store


If you are logged in to your computer with a domain account, you can use your Windows session credentials to connect to a vCenter or ESXi server. If you are not logged in to your computer with a domain account or your domain account has no rights in vSphere, you have to supply account information every time you connect to a vCenter or ESXi server.

To prevent yourself from having to do this, you can store credentials in the credential store. These stored credentials will be used as default if you connect to a server that is stored in the credential store. You can use the -SaveCredentials parameter of the Connect-VIServer cmdlet to indicate that you want to save the specified credentials in the local credential store, as follows:

PowerCLI C:\> Connect-VIServer -Server 192.168.0.132 -User admin
    -Password pass -SaveCredentials

You can also create a new entry in the credential store with the New-VICredentialStoreItem cmdlet:

PowerCLI C:\> New-VICredentialStoreItem -Host 192.168.0.132
    -User Admin -Password pass

You can not only store credentials for vCenter Servers but also for ESXi servers, using the following command:

PowerCLI C:\> New-VICredentialStoreItem -Host ESX1 -User root
    -Password VMware1!

To get a listing of all of your stored credentials, type the following command:

PowerCLI C:\> Get-VICredentialStoreItem

And to remove a stored credential you can use the following command:

PowerCLI C:\> Remove-VICredentialStoreItem -Host ESX1 -User root

The stored credentials are stored in a file on your computer. The default credential store file location is: %APPDATA%\VMware\credstore\vicredentials.xml. But it is also possible to create other credential store files. You can see the contents of the default credential store file with the following command:

PowerCLI C:\> Get-Content -Path $env:APPDATA\VMware\credstore
    \vicredentials.xml

The passwords stored in a credential store file are encrypted. But you can easily retrieve the stored passwords with the following command:

PowerCLI C:\> Get-VICredentialStoreItem |
>> Select-Object -Property Host,User,Password

Note

The passwords in the stored credentials are encrypted. Only the user who created the item can decrypt the password.

Previous PageNext Page
You have been reading a chapter from
Learning PowerCLI - Second Edition
Published in: Feb 2017Publisher: ISBN-13: 9781786468017
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime

Author (1)

author image
Robert van den Nieuwendijk

Robert van den Nieuwendijk is an IT veteran from the Netherlands with over thirty years of experience in Information Technology. He holds a bachelor degree in software engineering. After working a few years as a programmer of air traffic control and vessel traffic management systems, he started his own company Van den Nieuwendijk Informatica in 1988. Since then he has worked as a freelance systems administrator of OpenVMS, Windows Server, Linux, and VMware vSphere systems, for Dutch governmental organizations and cloud providers. During winter he is also a ski and snowboard instructor at an indoor ski school. With his background as a programmer, he always tries to make his job easier by writing programs or scripts to perform repeating tasks. In the past, he used the C programming language, OpenVMS DCL, Visual Basic Script and KiXtart to do this. Now, he uses Microsoft PowerShell and VMware PowerCLI for all of his scripting work. Robert is a frequent contributor and moderator at the VMware VMTN Communities. Since 2012 VMware awarded him the vExpert title for his significant contributions to the community and a willingness to share his expertise with others. He has a blog at http://rvdnieuwendijk.com where he writes mainly about VMware PowerCLI, Microsoft PowerShell, and VMware vSphere. If you want to get in touch with Robert, then you can find him on Twitter. His username is @rvdnieuwendijk. Robert is also the author of Learning PowerCLI, Packt Publishing.
Read more about Robert van den Nieuwendijk