VMware Cloud Community
vSohill
Expert
Expert
Jump to solution

New to PowerCLI

Hi,

How can I put all hosts under one variable or instance to run one command against all hosts.

Thank you

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You use an array (in fact PowerShell will do that for you).

So if you do

$esx = Get-VMHost

and if you have more than 1 ESXi node in your environment, the variable $esx will be an array, each element being one VMHost object.

Most of the PowerCLI cmdlets that take an ESXi node as a parameter, support giving more than one ESXi host.

That can be seen by looking at the square brackets on the cmdlet syntax.

esxi.png


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You use an array (in fact PowerShell will do that for you).

So if you do

$esx = Get-VMHost

and if you have more than 1 ESXi node in your environment, the variable $esx will be an array, each element being one VMHost object.

Most of the PowerCLI cmdlets that take an ESXi node as a parameter, support giving more than one ESXi host.

That can be seen by looking at the square brackets on the cmdlet syntax.

esxi.png


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

0 Kudos
vSohill
Expert
Expert
Jump to solution

Great

Thank you

0 Kudos