1 Reply Latest reply on Jun 10, 2019 11:30 PM by LucD

    Connect-Viserver Prompting For Creds w/ Credential Store Item

    nicktalbot77 Lurker

      I created a new vi credential store item with "new-vicredentialstoreitem", the cred shows up with get-vicredentialstoreitem, but if I try and connect with connect-viserver -host vicredstorehost, it prompts for creds instead of passing the cred store item through.

        • 1. Re: Connect-Viserver Prompting For Creds w/ Credential Store Item
          LucD Guru
          vExpertUser ModeratorsCommunity Warriors

          You will still need to connect with the Server parameter.
          The value you pass on the Server parameter should be the same that you used on the Host parameter with the New-VICredentialStoreItem.

          You can build this into a try-catch construct.

           

          $vcName = 'MyServer'

          try

          {

             Get-VICredentialStoreItem -Host $vcName -ErrorAction Stop | Out-Null

             Connect-VIServer -Server $vcName

          }

          catch

          {

             Write-Host "No entry for $vcName found in the credentialstore" -ForegroundColor red

          }