I need to change Network settings like described in this article. That works good so far. However I also need to know on what active network I make the changes.
(For a better understanding please open Control Panel\Network and Internet\ Network and Sharing Center
. Unfortunately all picture hosting sites are blocked by my company so I can't post a screenshot.)
Any help on how I can query what connection is associated with what network with WMI (or other technology)?
UPDATE:
I need to query a remote machine.
You can use the
NetworkListManager
COM component, either with dynamic as shown below or using the Windows API Code Pack which contains all the COM wrappers.PowerShell: