Hello there,
You can use the below powershell script to achieve this.
$port1 = New-Object -ComObject HNetCfg.FWOpenPort
$port1.Port = 80
$port1.Name = 'MyTestPort' # name of Port
$port1.Enabled = $true
$fwMgr = New-Object -ComObject HNetCfg.FwMgr
$profiledomain=$fwMgr.LocalPolicy.GetProfileByType(0)
$profiledomain.GloballyOpenPorts.Add($port1)
To specify a range of port numbers, separate the two numbers with a colon (:), such as -p tcp --dport 3000:3200. The largest acceptable valid range is 0:65535.
Use an exclamation point character (!) after the --dport option to match all packets which do not use that network service or port.
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--