finding a bunch of server’s ip address

March 31st, 2009 by Mr.M | No Comments »
  1. get-content server.txt| foreach {
  2. $strComputer = $_
  3. $colItems = get-wmiobject -class "Win32_NetworkAdapterConfiguration" `
  4. -computername $strComputer | Where{$_.IpEnabled -Match "True"}
  5. foreach ($objItem in $colItems) {
  6. write-host $strComputer " : " $objItem.IPAddress
  7. }
  8. }

in the server.txt file, one server per line and no extra space at the end of each server.

Leave a Reply

You must be logged in to post a comment.