Using Command-Line Utilities
As easy as Windows PowerShell is to use, there are times when it is easier to find information by using a command line utility. For example, to find IP configuration information you only need to use the _Ipconfig.exe _utility. You can type this directly into the Windows PowerShell console and read the output in the Windows PowerShell console. This command and associated output appears here in truncated form.
1
PS C:\> ipconfig
2
3
Windows IP Configuration
4
5
Wireless LAN adapter Local Area Connection\* 14:
6
7
Media State . . . . . . . . . . . : Media disconnected
8
Connection-specific DNS Suffix . :
9
10
Ethernet adapter vEthernet (WirelessSwitch):
11
12
Connection-specific DNS Suffix . : quadriga.com
13
Link-local IPv6 Address . . . . . : fe80::915e:d324:aa0f:a54b%31
14
IPv4 Address. . . . . . . . . . . : 192.168.13.220
15
Subnet Mask . . . . . . . . . . . : 255.255.248.0
16
Default Gateway . . . . . . . . . : 192.168.15.254
17
18
Wireless LAN adapter Local Area Connection\* 12:
19
20
Media State . . . . . . . . . . . : Media disconnected
21
Connection-specific DNS Suffix . :
22
23
Ethernet adapter vEthernet (InternalSwitch):
24
25
Connection-specific DNS Suffix . :
26
Link-local IPv6 Address . . . . . : fe80::bd2d:5283:5572:5e77%19
27
IPv4 Address. . . . . . . . . . . : 192.168.3.228
28
Subnet Mask . . . . . . . . . . . : 255.255.255.0
29
Default Gateway . . . . . . . . . : 192.168.3.100
30
31
<OUTPUT TRUNCATED>
Copied!
To obtain the same information using Windows PowerShell would require a more complex command. The command to obtain IP information is Get-NetIPAddress, But there are several advantages. For one thing, the output from the _IpConfig.exe _command is text, whereas the output from Windows PowerShell is an object. This means you can group, sort, filter, and format the output in an easy fashion.
The cool thing is that with Windows PowerShell console, you have not only the simplicity of the command prompt, but you also have the powerful Windows PowerShell language built in. Therefore, if you need to refresh Group Policy three times and wait for five minutes between refreshes, you can use the command appearing here (looping is covered in chapter eleven).
1
1..3 | % {gpupdate ; sleep 300}
Copied!
Last modified 3yr ago
Copy link