We use AD LDAP for our 2 vCenters with no issues. As fo scripts, I
have the credentials saved in an encrypted XML file. So my scheduled
scripts use that to log in.
I've snipped out a bit here, like ensuring that the credential file
exists first, but this is essentially what we do. Been doing it this
way for years ...
https://vdc-download.vmware.com/vmwb-repository/dcr-public/73d6de02-05fd-47cb-8f73-99d1b33aea17/850c6b63-eb82-4d9c-bfcf-79279b5e5637/doc/New-VICredentialStoreItem.html
https://virtuallyjason.blogspot.com/2017/01/creating-vicredentialstore-items.html
<#
Updates:
2022-10-14 Changed credential file to be used, pointing it at the
network share. --MJL
2023-07-24 Removed transcript. -- MJL
Designed to be run from host: <hostname> as user: <Username>
Note that the host names must be capital HOSTNAME, lowercase rest of
FQDN, as that's how they are entered
in the XML file that holds the vCenter credentials
Connects to each host in a vCenter, and saves the configuration
#>
Import-Module VMware.PowerCLI
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
-WebOperationTimeoutSeconds -1 -Scope User -InvalidCertificateAction
ignore -Confirm: $false -ParticipateInCEIP $true | Out-Null
$vCenterCredFile = "vCenter-Credentials.XML"
$All_vCenterds = ("<FQDN1>", "<FQDN2")
$envComputerName = Get-Item env:ComputerName
[string] $ComputerName = $envComputerName.Value
ForEach ($vCenter in $All_vCenters)
{
$vCenterCreds = Get-VICredentialStoreItem -Host $vCenter -File $vCenterCredFile
Connect-VIServer $vCenter -User $vCenterCreds.User -Password
$vCenterCreds.Password
}
When you save the credentials in the XML file, they are for *just*
that specific user and *just* that specific host. So if you try and
use those creds from a different host, it will fail to connect.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ntsysadmin/CAEuHzz%3DgXgi8qCZgsu0gJrqko%2Bg%3DHdApL%2BwM2DU_fxnRO5pPOA%40mail.gmail.com.