New-RDMPort
Synopsis
Generate port number(s) based on the specified parameters.
Syntax
__AllParameterSets
New-RDMPort [-Count <int>] [-ExcludePort <int[]>] [-IncludeWellKnownPorts] [-IncludeRegisteredPorts]
[-IncludePortsUsedByOthersSessions] [-Maximum <int>] [-Minimum <int>]
[-ForcePromptAnswer <DialogResult[]>] [<CommonParameters>]Description
Generate port number(s) based on the specified parameters.
Examples
Example 1
PS C:\> $port = New-RDMPort -Minimum 50 -Maximum 2048 -IncludeWellKnownPorts -IncludeRegisteredPorts -IncludePortsUsedByOthersSessionsGenerate a port between 50 and 2048. The port can be already used by another session, or be a well known or registered port.
Example 2
The port will have a value of either 10, 14 or 15. If another session use one of the ports, that port will be excluded from the possibilities.
Example 3
10 ports will be generated and stored in $ports.
Example 4
The user fetch an existing remote powershell session called ARemotePwsh and change its port. The new port in at least 1024, not a well known port, not a registered port and unused by other sessions. The user save the modification.
Parameters
-Count
Number of ports to be generated. Default value is 1.
-ExcludePort
Those ports will not be generated.
-ForcePromptAnswer
Switch to use with caution. It will automatically answer prompt asking yes/no, yes/no/cancel, or ok/cancel questions. In case of multiple prompts, multiple values can be passed to this parameter. Here are the accepted values:
Yes: Accept the prompt. Cover the OK and Automatic value.
No: Refuse the yes/no/cancel prompt. "Cancel" is the fallback option if there is no "No" option.
Cancel: Cancel the yes/no/cancel prompt. "No" is the fallback option if there is no "Cancel" option.
-IncludePortsUsedByOthersSessions
Allows ports used by others sessions to be generated.
-IncludeRegisteredPorts
Allows registered ports to be generated. For a list of registered ports, see: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Registered_ports
-IncludeWellKnownPorts
Allows well known ports to be generated. For a list of well known ports, see: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
-Maximum
Maximum port value generated. By default, the boundary is set at the absolute maximum 65 535.
-Minimum
Minimum port value generated. By default, the boundary is set at 0. A recommended value is 1024.
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Notes
For more information, type "Get-Help New-RDMPort -detailed". For technical information, type "Get-Help New-RDMPort -full".
Last updated
Was this helpful?