If you are connecting to either a vCenter server or a vSphere
Host the cmdlet is the same, you can use the Connect-VIServer cmdlet to connect
to both of these
C:\PS>Connect-VIServer vcenterserver -User admin -Password
admin
By default HTTPS and port 443 is assumed which is the same as
the vSphere Client or Web Client, unless you specify –port or –protocol
parameter for the cmdlet.
In the above example, we used username and password in the
plain text format which is unsafe! Hence there are multiple ways in which we
can specify the credentials or store the credentials
1. Pass-through
2. VICredentialStore
Pass-through
C:\PS>Connect-VIServer –Server vcenterserver
If we do not enter a username or password parameter just like
above example then the credentials of the current user are passed through to
the vCenter or vSphere host and used to try and authenticate the
connection. This is great if your environment is setup in the same domain
as your vCenter Server or your specific user account has been given access to
vCenter or the host.
VICredentialStore
VICredentialStore is the ability to store credentials for
connections to different vCenter Servers or vSphere hosts and vCloud Director (
Connect-CIServer cmdlet) using PowerCLI. This option helps us to connect without
specifying the username and password
For Example:
C:\PS>Connect-VIServer vcenterserver -User admin -Password
admin –SaveCredentials
Connect to a server and save the credentials in the
credential store. After the credentials are stored, you can connect to the
server without specifying them. To get a previously saved credential store
item, use the Get-VICredentialStoreItem cmdlet.
Get-VICredentialStoreItem:
This command retrieves the credential
store items available on a vCenter Server system.
New-VICredentialStoreItem: This Command creates a new entry in the credential store.
Remove-VICredentialStoreItem: This Command removes the specified credential store items.
The New-VICredentialStoreItem cmdlet creates a new
entry in the credential store and encrypts the password. If there is an
existing entry for the specified host and user, it is overwritten. If the
credential store file does not exist, it is created (along with its directory
if needed).
If no file is specified, the item is created in the default
credential store file %APPDATA%\VMware\credstore\vicredentials.xml.
An example of this command is shown below:
C:\PS>New-VICredentialStoreItem -Host ESX01 -User Admin
-Password admin
No comments:
Post a Comment