I had a need to test a port on a remote machine, but the internal TCP Port Monitor only works for the machine where it is assigned. I wrote this powershell script to test the port on the remote machine and thought I would share it here.
In it's current form, you can invoke the script with parameters from the command line. Let's run a test against Google's port 443.
.\TestRemotePort.ps1 -RemoteHost 142.250.68.238 -Port 443
Statistic: 1<br />Message: Port 443 on 142.250.68.238 is open.
If you are looking to use the script without any parameters, simply comment out or remove the following lines:
### REMOVE THIS BLOCK IF USING HARDCODED PARAMETERS ###
param (
[Parameter(Mandatory=$true)]
[string]$RemoteHost,
[Parameter(Mandatory=$true)]
[int]$Port
)
### REMOVE THIS BLOCK IF USING HARDCODED PARAMETERS ###
then, uncomment the following lines and supply the appropriate values for testing
# [string]$RemoteHost = "10.1.1.1"
# [int]$Port = 80