# Trying to combine 3 variables for elegant looking output

**URL:** <https://forums.powershell.org/t/trying-to-combine-3-variables-for-elegant-looking-output/21351>\
**Category:** PowerShell Help\
**Created:** [January 12, 2023, 2:42pm UTC](https://forums.powershell.org/t/trying-to-combine-3-variables-for-elegant-looking-output/21351 "2023-01-12T14:42:21Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 12, 2023, 6:12pm UTC](https://forums.powershell.org/t/trying-to-combine-3-variables-for-elegant-looking-output/21351/4 "2023-01-12T18:12:52Z")

</div>

> [@matt1974](#):
>
> ```auto
> foreach ($a in $esx) {
> $esx = 
> 
> ```

… that looks weird … how do you populate `$esx`? Using the same variable for the loop itself and defining it inside the loop cannot work. 🤔

What is it actually what you want to achieve? If you want to get information about each individual VMHost of a given cluster you may run something like this:

```auto
Get-Cluster -Name "swbdvcpyld01v.nslijhs.net" | 
Get-VMHost | 
ForEach-Object {
    $VMHostNetworkAdapter = Get-VMHostNetworkAdapter -VMKernel -VMHost $_
    $VMHostNetworkStack = Get-VMHostNetworkStack -VMHost $_

    [PSCustomObject]@{
        Hostname = $VMHostNetworkAdapter.VMHost
        IP = $VMHostNetworkAdapter.IP
        IPv6Enable = $VMHostNetworkStack.IPv6Enabled
        DnsAddress = $VMHostNetworkStack.DnsAddress
    }
}

```

!! You may adapt the queries inside the loop. You don’t provide the `VMHost` via pipeline - so you have to specify it.

---

_[View the full topic](https://forums.powershell.org/t/trying-to-combine-3-variables-for-elegant-looking-output/21351)._
