Windows Management Instrumentation (WMI) provides a way of accessing
details of your operating system that are normally hidden from the
Control Panel, Device manager or IpConfig. While there are 7 WMI
classes dealing with network properties, the most
versatile is: WMI Class Win32_NetworkAdapterConfiguration.
Topics for PowerShell Win32_NetworkAdapterConfiguration
While you could employ VBScript to interrogate
Win32_NetworkAdapterConfiguration, PowerShell is much easier and quicker
to learn. A reminder that the master cmdlet is Get-WmiObject,
indeed it's worth researching parameters and examples with Get-help
Get-WmiObject.
# PowerShell script to display network properties. # Author: Guy Thomas # Version 2.2
February 2010 tested on PowerShell v 1.0 and 2.0
Note 1: As usual, you can view all a PowerShell cmdlets
parameters with Get-Help, for example: Get-Help Get-WmiObject.
Note 2: You could use the alias PowerShell gwmi instead
of Get-WmiObject
Guy
Recommends: WMI Monitor and It's Free!
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems. Fortunately, Solarwinds
have created a
Free WMI Monitor so that you can discover these gems of performance
information, and thus improve your PowerShell scripts. Take the guess work out of which WMI counters to use when scripting the
operating system, Active Directory or Exchange Server.
I could tell you which properties to script, but it's much better if you
learn how to view the master list, then make selections to suit your
particular needs or project.
# Script to research properties of Win32_NetworkAdapterConfiguration # Author: Guy Thomas # Version 2.2
February 2010 tested on PowerShell v 1.0 and 2.0
Note 1: Above is a one-line command. Below is a
refinement to filter the properties that you are likely to be interested
in.
Note 2: A
reminder that even this command accepts Get-Help, thus you could try:
Get-Help Get-Member -full. My point is that help will reveal other
options, for example -MemberType Method.
# Script to research properties of Win32_NetworkAdapterConfiguration # Author: Guy Thomas # Version 2.5
February 2010 tested on PowerShell v 1.0 and 2.0
Encouraging computers to sleep when not in use is a great idea -
until you are away from your desk and need a file on that remote sleeping machine!
Wake-On-LAN really will save you that long walk to awaken a hibernating
machine; however my reason for encouraging you to download this utility is
just because it's so much fun sending those 'Magic Packets'. As Wake-On-LAN (WOL) is free, see
if I am right, and you get a kick from arousing those sleeping machines.
WOL also has business uses for example, wakening machines so that they can have
their patches applied.
Note 6: PowerShell has no word-wrap, thus the
backtick ` means continue on the next line. Beware, there should
be no space after the `.
Note 7: Observe PowerShell's trademark the (|) pipe
symbol, this means that the output of the main command is pumped into
Format-Table. Now we can decide which or the dozens of possible
properties to display.
Example which filters for 'real' IP addresses. It
also displays the default gateway and the MAC address.
# PowerShell script to list your computer's IP address(es) # Author: Guy Thomas # Version 1.5
February 2010 tested on PowerShell v 1.0 and 2.0
Note 8: You could replace Where-Object {$_.IPEnabled -eq 'True'}
with a -filter parameter. Check the syntax with Get-Help
Get-WmiObject -full.
Note 9: PowerShell has no word-wrap, thus the
backtick ` means continue on the next line. Beware, there should
be no space after the `.
Guy Recommends: A Free Trial of the Network Performance Monitor
(NPM)
Solarwinds'
Orion performance monitor
will help you discover what's happening on your network. This
utility will also guide you through troubleshooting; the dashboard will
indicate whether the root cause is a broken link, faulty equipment or
resource overload.
Perhaps the NPM's best feature is the way it suggests solutions to network
problems. Its
second best feature is the ability to monitor the health of individual VMWare
virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you take advantage of Solarwinds' offer.
The additional feature of this script is that refines the search
from the broad 'Win32', to the narrower 'Win32_Network'. The
result is a list of network WMI classes.
# PowerShell example to list every WMI class matching Win32_network # Author: Guy Thomas # Version 1.5
February 2010 tested on PowerShell v 1.0 and 2.0
Note 10: In practical terms, most of the 7
network classes are disappointing. However, the class
win32_networkadapter has the useful property of netconnectionstatus, and
also the handy methods: 'Enable' and Disable'.
»
Summary of WMI Class Win32_NetworkAdapterConfiguration
The key information that PowerShell's Get-WmiObject needs is a WMI class.
These Win32_NetworkAdapterConfiguration examples will help you to research the best
properties for your task.
For pure PowerShell research remember Get-Help and Get-Member.
If you like this page then please share it with your friends
Please email me if you have any example scripts. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.