Automation

 View Only
  • 1.  Centralize Credentials Get-VICredentialStoreItem

    Posted Feb 06, 2018 04:09 PM

    Hi All,

    Working on an Audit script run from the audit server that uses a generic account with Read Only access to all vCenters.  I would like to use the VICredentialStoreItem to store the credentials and have the script pull the credentials rather than sharing the credentials with those that would use the script.

    I have tried this but no luck.

    $vCenter = 'vc1','vc1'

    $vCenterUser = 'ReadOnlyAccount'


    foreach ($vC in $vCenter) {

         if (Test-Connection $vC -Count 2 -Quiet) {

              Connect-VIServer -Server $vC -Credential (Get-VICredentialStoreItem -Host $VC -User $vCenterUser -File 'C:\creds.xml')

         }

         else {}




  • 2.  RE: Centralize Credentials Get-VICredentialStoreItem
    Best Answer

    Posted Feb 06, 2018 04:39 PM

    The Get-VICredentialStoreItem does not return a PSCredential object, as is required on the Credential parameter.

    Try like this

    $credItem = Get-VICredentialStoreItem -Host $VC -User $vCenterUser -file “C:\creds.xml”

    Connect-viserver -Server $credItem.Host -User $credItem.User -Password $credItem.Password