1 Replies - 335 Views - Last Post: 03 December 2018 - 02:25 AM Rate Topic: -----

#1 mulliganesx   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-December 18

(PowerShell) Get-VICredentialStoreItem : Cannot convert 'System.Ob

Posted 02 December 2018 - 04:23 PM

Unable to connect to vCenter with stored credentials. Am I missing anything? I can see my credentials and able to read in the vCenters, username etc. when I run $creds.host.

I posted the way I created the credentials as well as the script to pull remotely. This will be ran as a scheduled task.

Error I am receiving:
Get-VICredentialStoreItem : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Host'. Specified method is not supported.


## Create XML Encrypted File ##
$vCenterServer = "VCENTER01.DOMAIN.NET","VCENTER02.DOMAIN.NET"

## ForEach add multiple vCenters to File
$vCenterServer |
    Foreach-Object{
     New-VICredentialStoreItem -Host $_ -User Domain\Username -Password 'PASSWORD' -File "E:\Creds\Creds.xml"
}

 

 

###
## Script Below
###

#Load Modules
Get-Module -Name VMware* -ListAvailable | Import-Module

$vCenterServer = "VCENTER01.DOMAIN.NET","VCENTER02.DOMAIN.NET" 
$creds = Get-VICredentialStoreItem -Host $vCenterServer -File "E:\Creds\Creds.xml"

#Use the $Credentials variable for the username and password switches in the Connect-VIServer
Connect-VIServer -Server $creds.host -User $creds.User -Password $creds.Password

 
#List VMware Hosts in Maintenance Mode, and Notes

Get-VMHost -Location DC01,DC02 | Where-Object {$_.ConnectionState -eq "Maintenance"} |
Get-Annotation -Name 'Notes' |
Select @{N='VMHost';E={$_.AnnotatedEntity.Name}},
       @{N='ConnectionState';E={$_.AnnotatedEntity.ConnectionState}},
       value |
ConvertTo-HTML | Out-File "C:\inetpub\wwwroot\Report\ESXReport.html"


Is This A Good Question/Topic? 0
  • +

Replies To: (PowerShell) Get-VICredentialStoreItem : Cannot convert 'System.Ob

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6805
  • View blog
  • Posts: 28,134
  • Joined: 12-December 12

Re: (PowerShell) Get-VICredentialStoreItem : Cannot convert 'System.Ob

Posted 03 December 2018 - 02:25 AM

Re-read the error message:

Quote

Get-VICredentialStoreItem : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Host'. Specified method is not supported.


The method is expecting a single string for the Host parameter, $vCenterServer is not a string.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1