Skip to content

Commit 15e69b8

Browse files
committed
Script added to generate port list from web
1 parent ca54718 commit 15e69b8

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

Scripts/Create-PortListFromWeb.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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")
895 KB
Binary file not shown.

0 commit comments

Comments
 (0)