File tree Expand file tree Collapse file tree
Source/NETworkManager/Resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # [xml]$LatestPorts = Get-Content -Path "$PSScriptRoot\Service Name and Transport Protocol Port Number Registry.xml"
2+ [xml ]$LatestPorts = (Invoke-WebRequest - Uri " https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml" ).Content
3+
4+ $Output = " "
5+
6+ foreach ($record in $LatestPorts.ChildNodes.record )
7+ {
8+ if ([string ]::IsNullOrEmpty($record.number ) -or ([string ]::IsNullOrEmpty($record.protocol )))
9+ {
10+ continue
11+ }
12+
13+ $Description = ($record.description -replace ' `n' , ' ' ) -replace ' \s+' , ' '
14+
15+ $Number = $record.number
16+
17+ if ($Number -like " *-*" )
18+ {
19+ $NumberArr = $Number.Split (' -' )
20+
21+ foreach ($Number1 in $NumberArr [0 ].. $NumberArr [1 ])
22+ {
23+ $Output += " $Number1 |$ ( $record.protocol ) |$ ( $record.name ) |$Description `n "
24+ }
25+ }
26+ else
27+ {
28+ $Output += " $Number |$ ( $record.protocol ) |$ ( $record.name ) |$Description `n "
29+ }
30+ }
31+
32+ Out-File - InputObject $Output - FilePath (Join-Path - Path (Split-Path $PSScriptRoot - Parent) - ChildPath " Source\NETworkManager\Resources\ports.txt" )
You can’t perform that action at this time.
0 commit comments