【PowerShell专栏】利用PowerShell开启端口的监听
下面的内容,我们用于在一台服务器开启端口的监听,下面的内容是具体的脚本代码。
param (
[parameter(Mandatory = $false, HelpMessage = "Enter the tcp port you want to use to listen on, for example 3389")]
[ValidatePattern('^[0-9]+$')]
[ValidateRange(0, 65535)]
[int]$TCPPort,
#定义是否监听TCP端口
[parameter(Mandatory = $false, HelpMessage = "Enter the udp port you want to use to listen on, for example 3389")]
[ValidatePattern('^[0-9]+$')]
[ValidateRange(0, 65535)]
[int]$UDPPort
#定义是否监听的是UDP端口
)
#判断监听的是TCP是否和TCP 一起监听,提示不支持
if ($TCPPort -and $UDPPort) {
Write-Warning (&#