troubleshooting Question

Construct a single windows command line to perform a VMware PowerCLI function or a script where I can pass parameters

Avatar of erlythornton
erlythornton asked on
PowershellVMware
13 Comments1 Solution5202 ViewsLast Modified:
Hello,

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.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros