I decide that I am interested in four specific properties, so I can write the command shown here. PS C:\> Get-NetTCPConnection | Get-Member -MemberType property | Format-Table name, definition -AutoSizeĪggregationBehavior uint16 AggregationBehavior To find which properties are available, I first use the Get-Member cmdlet as shown here. Because these are objects, it is a simple matter of choosing the properties that I want to see. PS C:\> Get-NetTCPConnection | group localport -NoElement | sort count -DescendingĪfter I have done this, I decide to obtain more information. I can easily see this by grouping by LocalPort as shown here. I might be curious and want to see what ports are being utilized. PS C:\> Get-NetTCPConnection | group state -NoElement For example, I can quickly see the state of the connections on my computer by grouping by state. Get-NetTCPConnection -AppliedSetting internetīut keep in mind these are objects, and you can parse the information via Windows PowerShell. To view connections to the Internet, use the AppliedSetting parameter as shown here. The command and the associated output are shown in the image that follows. For example, if I am interested in only established connections, I use the state parameter, and I tell it to show established connections. The nice thing about using the Get-NetTCPConnection cmdlet is that it returns objects, and it also has a number of useful switches. The image that follows illustrates the default output. On a larger monitor, using the default sizing for Windows PowerShell, the output is just fine. For me, the display does not scale properly in my default Windows PowerShell size, but that is due to my need to take screenshots. The default view of the Get-NetTCPConnection cmdlet is pretty useful, and it displays a decent amount of information about local and remote ports. (I am not good enough with regular expressions to type very complicated patterns on the fly in front of a live audience without a lot of prior work-for example, say at Tech Mentor.)Īs long as I do not need to do any post processing, and as long as I can remember the netstat –ano command (yes, you can gang the switches for netstat), there is no problem with the command. Thus, the requirement for a bit of regular expression work. The problem with netstat (it is not case sensitive) is that it returns string data instead of objects. Using NetStat is easy (as long as you remember that it is netstat and not net statistics, and you remember what the switch –a –n –o accomplishes). I like things that are in the box as much as possible. This is a good thing, because gaining access to the SNMP namespace requires installing SNMP, and that requires evaluation and planning. In Windows PowerShell 3.0 in Windows 8, I use a simple cmdlet. The second time, I used the NetStat command-line utility tool, I wrote it in Windows PowerShell 1.0, and I parsed the output by using regular expressions. The first time I wrote it, I used a WMI class from the root/snmp namespace, and I wrote the script in VBScript. This is the third time I have written a script to obtain information about network connections. It’s a cool presentation if I do say so myself. I will be speaking about using Windows PowerShell 3.0 to manage a remote Windows 8 workstation. The Scripting Wife and I will be attending the first ever Cincinnati, Ohio Windows PowerShell User Group while we are in the area. My good friend (and fellow Microsoftee), Robert from California, is flying in for the class, so we are looking forward to seeing him again. Teresa will be out and about visiting friends and going to outlet malls and finding cool places to eat. The Scripting Wife and I are heading to northern Kentucky where I will be teaching a Windows PowerShell class to a customer there. The Scripting Wife has been busy finding water and soda on sale at various stores (shopping is one of her core skills), and the rest of the team has been busy working on sponsor layout drawings, presentations, and so on. In fact, as far as I know, we have even had our last organizational meeting. There are only twenty-three days until Windows PowerShell Saturday in Charlotte, North Carolina. Microsoft Scripting Guy, Ed Wilson, is here. Summary: Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell to identify port connections in Windows 8.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |