I need to execute a windows command line the invokes VMware PowerCLI to connect to my server and then perform a few more commands. As a test I have tried to send out the following just to see if I could get an inventory to display and it gives me the following error.
C:\Documents and Settings\Administrator>C:\WINDOWS\system32\windowspowershell\v1
.0\powershell.exe -psc "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\
vim.psc1" -noe -c "Connect-VIServer -Server esxserver.company.com -Protocol https -User
myusername -Password mypassword | Get-Inventory"
WARNING: There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated in a root
certificate which isn't trusted by the trust provider.
* The X509 chain is not valid due to an invalid time value, such as a value
that indicates an expired certificate.
* The certificate's CN name does not match the passed value.
Get-Inventory : The input object cannot be bound to any parameters for the comm
and either because the command does not take pipeline input or the input and it
s properties do not match any of the parameters that take pipeline input.
At line:1 char:116
+ Connect-VIServer -Server esxserver.company.com -Protocol https -User myusername -Pass
word mypassword | Get-Inventory <<<<
Alternatively I could try to do the connect in a batch file but then I would need to pass parameters to it from the command line also. For example I could put the Connect-VIServer in the ps1 file but I need to pass the server hostname, user and password then in one of the later commands I need to pass some more variables.
Please help me with any suggestions as to what I am doing wrong and the command line only without having to use a ps1 file is preferable.