I have a question. Im making a port scanner and i want to make jobs for every port it scans if its open or not.
$endport = 100
$timeout = 100
$ipadres = "192.168.0.137"
$testPort = {
Param($port)
$tcpClient.ConnectAsync($ipadres, $port).Wait($timeout)
}
For($i=1; $i -le $endport; $i++) {
Start-Job -scriptblock $testPort -ArgumentList $i
}
Get-Job | Wait-Job
$out = Get-Job | Receive-Job
$out
So in this example i want to scan the ip adress 192.168.0.137 from port 1 to 100. But when i run this and show the result of my job i get this error
You cannot call a method on a null-valued expression.
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
+ PSComputerName : localhost
Does anybody have an idea how i can solve this?
$tcpClientinitialized? - Jesse