M
M
Misha Shav2020-09-16 09:00:25
PowerShell
Misha Shav, 2020-09-16 09:00:25

Why doesn't Job work when called remotely?

Good afternoon, gentlemen) I’ve been fighting for the second day, but I can’t do anything, I’ll have to ask)
Subject 2:
I have:
WS 2012 R2 with OpenSSH on board
powershell script
Task: implement remote procedure call AsJob
As you want: be able to enter 1 on the necessary PCs line of the form

ssh [email protected] powershell -file "path\to\script" args

How it is now: Now it works if you run the script locally / log in with ssh and then run the script. It also works if the script is not run asynchronously, as a background process, but synchronously. However, after entering
ssh [email protected] powershell -file "path\to\script" args
You have to wait a long time for the script to run. If you implement this AsJob, then it starts background processes, ends the SSH session and ... dies with it)
I would like to be able to run the script in the background without waiting for completion at all and without unnecessary inputs, if possible. Can you suggest how it can be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2020-09-16
@SeanCooper

background processes in powershell run in the same process in which they are running, it's like bg in the shell. with the dying of the shell and the processes die.
you need to open Persistent Sessions. but they will also need to be stored so that
https://docs.microsoft.com/en-us/powershell/module...
or create tasks with the scripts you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question