I have question on how to "reuse" a running powershell:
Situation:
I have a Streamdeck where I can fire up Powershell commands with different buttons.
I managed to get a powershell script (which was a hustle itself with my lack of coding knowledge)
that opens up a connection to another PC (IP/Port).
Keeping the shell open, I can type commands to be executed on the remote PC.
When I put those commands in a script to be fired up by a different streamdeck-button, the streamdeck opens up another shell trying to send the command.
Problem: the new shell doesn t know the existing tcp-connection .. so...no command comes through.
How can I either tell the new shell to use the existing connection or how can I make the connection "globally" accessible by different powershells?
This does the connection:
$RemotePC = "xxx.xxx.xxx.xxx"
$CPort = "yy"
$tcpConnection = New-Object System.Net.Sockets.TcpClient ($RemotePC , $CPort)
$tcpStream = $tcpConnection.GetStream()
$writer = New-Object System.IO.StreamWriter($tcpStream)
$writer.AutoFlush = $true
Hope my problem is not too trivial...and yes, I googled a lot ;)
Thanx
question from:
https://stackoverflow.com/questions/65599163/sending-commands-to-existing-powershell-with-streamdeck-buttons 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…