none
Trying to understand output from powershell script RRS feed

  • Question

  • I adapted the following script I found online, but find the output is weird when I run it on a remote PC.

    Locally I only get one response for each nic (I have several on my PC). Remotely though run on a computer with only one nic it gives me the info 3 times for some reason:

    $strComputer = "remotePC"
    $NetworkAdptr = get-wmiobject -class "Win32_NetworkAdapterConfiguration" `
    -computername $strComputer | Where{$_.IpEnabled -Match "True"}
       foreach ($objItem in $NetworkAdptr) {
       write-host "MAC Address : " $objItem.MACAddress
       write-host "IPAddress : " $objItem.IPAddress
       write-host "IPAddress : " $objItem.IPEnabled
       write-host "DNS Servers : " $objItem.DNSServerSearchOrder
       write-host "DHCP Enabled? : " $objItem.DHCPEnabled
       write-host "DHCP Server : " $objItem.DHCPServer
       write-host "DNSDomain : " $objItem.DNSDomain
       write-host "DNSHostName : " $objItem.DNSHostName
       write-host "TCP/IP Filtering Enabled? : " $objItem.IPFilterSecurityEnabled
       write-host ""   
    }

    I get:


    MAC Address :  11:11:11:11:11:11
    IPAddress :  192.168.1.100
    IPAddress :  True
    DNS Servers :  10.123.123.123 10.123.123.124
    DHCP Enabled? :  False
    DHCP Server :
    DNSDomain :  mydom.com
    DNSHostName :  remotePC
    TCP/IP Filtering Enabled? :  False

    MAC Address :  11:11:11:11:11:11
    IPAddress :  192.168.1.100
    IPAddress :  True
    DNS Servers :
    DHCP Enabled? :  True
    DHCP Server :  255.255.255.255
    DNSDomain :
    DNSHostName :  remotePC
    TCP/IP Filtering Enabled? :  False

    MAC Address :  11:11:11:11:11:11
    IPAddress :  192.168.1.100
    IPAddress :  True
    DNS Servers :  10.123.123.125 10.123.123.124
    DHCP Enabled? :  False
    DHCP Server :
    DNSDomain :  mydom.com
    DNSHostName :  remotePC
    TCP/IP Filtering Enabled? :  False

    All the mac address are the same and I know there is only one nic in this computer, but why are some setting different? Its the same nic, but it lists three -some with different domain/dns server entries. Is there a configuration file somewhere its reading?

    Thanks for any responses I'd really like to understand this better.

     

     

     

     

    Friday, March 26, 2010 1:39 PM

Answers

  • I ran your script here.  The code runs fine.  Multiple Domain references?  Is there a chance under the DNS config you have more settings or the "Alternate Settings" on that machine is populated?

    Also is this remote computer a physical or Virtual computer?

    Sean


    Powershell. It's so Easy and it's FREE! Dive in and use it now, It'll take no time. :) http://www.energizedtech.com http://www.itprotoronto.ca
    • Marked as answer by red888 Friday, March 26, 2010 4:12 PM
    Friday, March 26, 2010 3:55 PM
    Moderator

All replies

  • I ran your script here.  The code runs fine.  Multiple Domain references?  Is there a chance under the DNS config you have more settings or the "Alternate Settings" on that machine is populated?

    Also is this remote computer a physical or Virtual computer?

    Sean


    Powershell. It's so Easy and it's FREE! Dive in and use it now, It'll take no time. :) http://www.energizedtech.com http://www.itprotoronto.ca
    • Marked as answer by red888 Friday, March 26, 2010 4:12 PM
    Friday, March 26, 2010 3:55 PM
    Moderator
  • This is a physical PC. It reassuring at least to know its not the script I ran it myself on another PC and only got one result. When I take a look at the remote computer I'll check the settings.

     

    But for my general understanding what is Win32_NetworkAdapterConfiguration actually accessing? Is it registry stuff?

    Friday, March 26, 2010 4:11 PM
  • You need to check the MappingStrings qualifier for each property. Here are its values for Win32_NetworkAdapterConfiguration properties used in your script:

    MACAddress - Win32API|Device Input and Output Functions|DeviceIoControl
    IPAddress - Win32Registry|System\CurrentControlSet\Services|Parameters\Tcpip|IPAddress
    IPEnabled - Win32Registry|System\CurrentControlSet\Services|Parameters\Tcpip
    DNSServerSearchOrder - Win32Registry|SYSTEM\CurrentControlSet\Services\Tcpip\Parameters|NameServer
    DHCPEnabled - Win32Registry|SYSTEM\CurrentControlSet\Services|EnableDHCP
    DHCPServer - Win32Registry|SYSTEM\CurrentControlSet\Services|DhcpServer
    DNSDomain - Win32Registry|SYSTEM\CurrentControlSet\Services\Tcpip\Parameters|Domain
    DNSHostName - Win32Registry|SYSTEM\CurrentControlSet\Services\Tcpip\Parameters|Hostname
    IPFilterSecurityEnabled - Win32Registry|SYSTEM\CurrentControlSet\Services\Tcpip\Parameters|IPFilterSecurityEnabled

     

    So, most of these come from registry, but MAC address information is obtained with Win32 API.


    Uros Calakovic
    Friday, March 26, 2010 8:53 PM
    Moderator