VMware Cloud Community
Anishkumarv
Enthusiast
Enthusiast
Jump to solution

connect Multiple ESX in my script.

   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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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 ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Anishkumarv
Enthusiast
Enthusiast
Jump to solution

yes lucd for all esx i have same credentials.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Anishkumarv
Enthusiast
Enthusiast
Jump to solution

Thanks lucd,

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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:)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Anishkumarv
Enthusiast
Enthusiast
Jump to solution

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. 😞

Reply
0 Kudos