get all Exchange Servers and their IP addresses…

As one line:

foreach($s in (get-ExchangeServer)){$ipconfigSet = get-wmiObject Win32_NetworkAdapterConfiguration -ComputerName $s.fqdn; foreach($ipconfig in $ipconfigSet ){if($ipconfig.IPAddress){foreach($ip in $ipconfig.IPAddress){"{0}     {1}" -f $s,$ip}}}}

Readable:

foreach($s in (get-ExchangeServer))
{
    $ipconfigSet = get-wmiObject Win32_NetworkAdapterConfiguration -ComputerName $s.fqdn
    foreach($ipconfig in $ipconfigSet )
    {
        if($ipconfig.IPAddress)
        {
            foreach($ip in $ipconfig.IPAddress)
            {
                # write to the screen
                "{0}     {1}" -f $s,$ip
            }
        }
    }
}

–Gene

One Comment on “get all Exchange Servers and their IP addresses…”

Leave a Reply