Automation

 View Only
  • 1.  connect Multiple ESX in my script.

    Posted Jul 11, 2013 11:09 AM

       Dear All,

    How to connect mulitple esx, i am writing  a script to connect multiple esx at one time and get vmhost detials.

    i tried like this in my script .

    $esx = (Get-Content "C:\Desktop\vmlist.txt") Connect-VIServer $esx

    how to connect with credentials . please guide me to resolve this thread.



  • 2.  RE: connect Multiple ESX in my script.

    Posted Jul 11, 2013 11:13 AM

    You can do

    $esx = Get-Content "C:\Desktop\vmlist.txt"

    Connect-VIServer $esx

    but that is without the credentials.

    Do you have the same credentials for each host ?



  • 3.  RE: connect Multiple ESX in my script.

    Posted Jul 11, 2013 11:15 AM

    yes lucd for all esx i have same credentials.



  • 4.  RE: connect Multiple ESX in my script.
    Best Answer

    Posted Jul 11, 2013 11:26 AM

    Then you should be able to do

    $esx = Get-Content "C:\Desktop\vmlist.txt"

    Connect-VIServer $esx -User YourUser -Password YourPassword

    To avoid having the password in clear text, you can also use the Credential parameter

    $esx = Get-Content "C:\Desktop\vmlist.txt"

    Connect-VIServer $esx -Credential $cred

    There are many ways to get the credentials into the $cred variable..

    Alan discusses the VICredentialStore in his Back to Basics: Connecting to vCenter or a vSphere Host post.



  • 5.  RE: connect Multiple ESX in my script.

    Posted Jul 11, 2013 11:45 AM

    Thanks lucd,

    Its working great. if you are free kindly answer my previous post.



  • 6.  RE: connect Multiple ESX in my script.

    Posted Jul 11, 2013 11:53 AM

    You mean this post Re: ESX / DATASTORE details in inventory list. ?

    I'm pretty sure Matt you will reply to your questions when he is online (remember the timezones :smileygrin:)



  • 7.  RE: connect Multiple ESX in my script.

    Posted Jul 11, 2013 12:00 PM

    yes :-) i am trying from yesterday, i dnt know why the empty spaces coming. in the ip field for most of the esx iam getting the same. :-(