VMware Cloud Community
vin01
Expert
Expert
Jump to solution

saving multiple vcenter cred using New-VICredentialStoreItem

Hi folks

How to save multiple vcenters credentials in single .xml file and call single vcenter once using that .xml file.

ex:

$vcenterserver="vcenter1","vcenter2","vcenter3","vcenter4"

New-VICredentialStoreItem -Host $vcenterserver  -User domain\domainuser -Password 'password' -File "C:\cred.xml"

its fail with below error

vicrederror.JPG

after executing as below if i supply host values "vcenter1","vcenter2","vcenter3","vcenter4" then its saving in .xml

New-VICredentialStoreItem   -User domain\domainuser -Password 'password' -File "C:\cred.xml"

Regards Vineeth.K
Reply
0 Kudos
1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

Hello, -

The issue there is that the -Host parameter only takes a single value.  If you pass each vCenter server name to the cmdlet, you should be able to achieve the thing you are intending to do.  Like:

## for each server name in $vcenterserver, call New-VICredentialStoreItem
$vcenterserver | Foreach-Object {New-VICredentialStoreItem -Host $_ -User domain\domainuser -Password 'password' -File "C:\cred.xml"}

Then, the file c:\cred.xml should have those four credentials in it.  How does that do for you?

View solution in original post

Reply
0 Kudos
2 Replies
mattboren
Expert
Expert
Jump to solution

Hello, -

The issue there is that the -Host parameter only takes a single value.  If you pass each vCenter server name to the cmdlet, you should be able to achieve the thing you are intending to do.  Like:

## for each server name in $vcenterserver, call New-VICredentialStoreItem
$vcenterserver | Foreach-Object {New-VICredentialStoreItem -Host $_ -User domain\domainuser -Password 'password' -File "C:\cred.xml"}

Then, the file c:\cred.xml should have those four credentials in it.  How does that do for you?

Reply
0 Kudos
vin01
Expert
Expert
Jump to solution

Hello mattboren

This worked perfectly.Thank youSmiley Happy

Regards Vineeth.K
Reply
0 Kudos