You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I was able to put together a hacky solution for this
with wsman, RunspacePool(wsman) as pool:
ps = PowerShell(pool)
ps.add_script(command)
ps.add_cmdlet("Out-String").add_parameter("Stream")
ps.begin_invoke() # execute process in the background
while ps.state == PSInvocationState.RUNNING:
current_output = [str(s) for s in ps.output]
if current_output:
print("\n".join(current_output))
ps.output = []
ps.poll_invoke() # update the output streams
Essentially the above, the old pypsrp API only allows intermediate output with poll_invoke(). The new psrp API which is still in beta is a lot more flexible and can run things in a separate thread of asyncio context to do it a bit more easily.
I try to use ping command
Need to wait for the execution to end before returning the result
How to return in real time?
tks
Actually, I need to call other scripts and return values in real time.
Using the ping command as an example
The text was updated successfully, but these errors were encountered: