mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 21:07:40 +02:00
Cleanup
This commit is contained in:
@ -8,17 +8,17 @@
|
||||
|
||||
param([string]$TargetIP, [int]$TargetPort, [string]$Message)
|
||||
|
||||
if ($TargetIP -eq "" ) {
|
||||
$TargetIP = read-host "Enter target IP address"
|
||||
}
|
||||
if ($TargetPort -eq 0 ) {
|
||||
$TargetPort = read-host "Enter target port"
|
||||
}
|
||||
if ($Message -eq "" ) {
|
||||
$Message = read-host "Enter message to send"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($TargetIP -eq "" ) {
|
||||
$TargetIP = read-host "Enter target IP address"
|
||||
}
|
||||
if ($TargetPort -eq 0 ) {
|
||||
$TargetPort = read-host "Enter target port"
|
||||
}
|
||||
if ($Message -eq "" ) {
|
||||
$Message = read-host "Enter message to send"
|
||||
}
|
||||
|
||||
$IP = [System.Net.Dns]::GetHostAddresses($TargetIP)
|
||||
$Address = [System.Net.IPAddress]::Parse($IP)
|
||||
$Socket = New-Object System.Net.Sockets.TCPClient($Address,$TargetPort)
|
||||
@ -31,9 +31,9 @@ try {
|
||||
$Stream.Close()
|
||||
$Socket.Close()
|
||||
|
||||
echo "Done."
|
||||
write-output "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
Reference in New Issue
Block a user