How to keep PowerShell process open with input/output on runtime? Announcing the arrival of...

Gastric acid as a weapon

How does cp -a work

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Storing hydrofluoric acid before the invention of plastics

Right-skewed distribution with mean equals to mode?

Should I discuss the type of campaign with my players?

I am not a queen, who am I?

How can I fade player when goes inside or outside of the area?

What causes the vertical darker bands in my photo?

Are my PIs rude or am I just being too sensitive?

Is there a Spanish version of "dot your i's and cross your t's" that includes the letter 'ñ'?

How to bypass password on Windows XP account?

Java 8 stream max() function argument type Comparator vs Comparable

Why did the IBM 650 use bi-quinary?

How to assign captions for two tables in LaTeX?

Do I really need recursive chmod to restrict access to a folder?

Is high blood pressure ever a symptom attributable solely to dehydration?

Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?

What LEGO pieces have "real-world" functionality?

What are the motives behind Cersei's orders given to Bronn?

Did Kevin spill real chili?

How do I mention the quality of my school without bragging

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?

List *all* the tuples!



How to keep PowerShell process open with input/output on runtime?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Pipeline input to executable with PowerShellSeparate input and output panelsHow to install a Windows Feature on Docker container (Windows 2016 Server) that requires a “server restart”?PowerShell & Batch Files With User InputIs it possible to get the Process ID of an Executable started in a PowerShell script using he 'Call' (`&`) operator?Autofill Read-Host input with PowerShellPowershell output with namesHow do I install and import the Powershell Community Extensions for a normal user?PowerShell Email with Text InputHow to install modules in powershell core 6.1 on linux





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm researching these days on how to can I keep a powershell process alive so I can run PS code without opening a new process each time.



The need: - Running multiple PS scripts dynamically, so they have the same base (custom) modules, as efficient as possible.



Be able to communicate with stdout/stdin/stderr of these scripts process while it is still running.



Ideally I'd want one process to open with a docker, import my modules, and then collect the code itself to run, run it in the same process as the one already opened so it won't have to open another process nor import again my modules.



The problem: - Setting up PS process in a docker container takes tremendous amount of time. (Roughly 2.5s, before I have even begun to run any code, and I'm talking about the PS process alone)



As of yet I did not find a PS way to run dynamic code on the same process without creating a new process & importing my modules again. Nor did I find a way to dynamically communicate with the new process while it still runs.
Possible Solutions: - Create the initial PS process with -noprofile so it won't load so slowly. (I am yet to test this, but folks on redit seems to be approving of this method) - Use start-process with -NoNewWindow flag, so it will generate new process each time but I guess the initial setup time will be spared. - Trying to use Invoke-Expression on big chunks of code, but from what I understand that is not recommended and probably won't let actively communicate with the code running there until it finishes.



And

Invoke-Expression```
Are the only relevant mechanisms I could find so far.

I've been told AWS lambda features similar functionality as what I am trying to achieve, but looking at it's code I did not make much progress, figured might be worth asking for help from people who are smarter then me :) Any help would be much appreciated. I do not seek for already fully working 3ed side solution, simply being able to mimic that behavior in PS code would be good enough for me.









share|improve this question







New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Why do you need to communicate with stdout/stdin/stderr of PowerShell host process? Does your scripts interacts with them explicitly?

    – PetSerAl
    21 hours ago











  • Yes, they should pass information in real time between them.

    – Yarden Sade
    12 hours ago


















0















I'm researching these days on how to can I keep a powershell process alive so I can run PS code without opening a new process each time.



The need: - Running multiple PS scripts dynamically, so they have the same base (custom) modules, as efficient as possible.



Be able to communicate with stdout/stdin/stderr of these scripts process while it is still running.



Ideally I'd want one process to open with a docker, import my modules, and then collect the code itself to run, run it in the same process as the one already opened so it won't have to open another process nor import again my modules.



The problem: - Setting up PS process in a docker container takes tremendous amount of time. (Roughly 2.5s, before I have even begun to run any code, and I'm talking about the PS process alone)



As of yet I did not find a PS way to run dynamic code on the same process without creating a new process & importing my modules again. Nor did I find a way to dynamically communicate with the new process while it still runs.
Possible Solutions: - Create the initial PS process with -noprofile so it won't load so slowly. (I am yet to test this, but folks on redit seems to be approving of this method) - Use start-process with -NoNewWindow flag, so it will generate new process each time but I guess the initial setup time will be spared. - Trying to use Invoke-Expression on big chunks of code, but from what I understand that is not recommended and probably won't let actively communicate with the code running there until it finishes.



And

Invoke-Expression```
Are the only relevant mechanisms I could find so far.

I've been told AWS lambda features similar functionality as what I am trying to achieve, but looking at it's code I did not make much progress, figured might be worth asking for help from people who are smarter then me :) Any help would be much appreciated. I do not seek for already fully working 3ed side solution, simply being able to mimic that behavior in PS code would be good enough for me.









share|improve this question







New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Why do you need to communicate with stdout/stdin/stderr of PowerShell host process? Does your scripts interacts with them explicitly?

    – PetSerAl
    21 hours ago











  • Yes, they should pass information in real time between them.

    – Yarden Sade
    12 hours ago














0












0








0


1






I'm researching these days on how to can I keep a powershell process alive so I can run PS code without opening a new process each time.



The need: - Running multiple PS scripts dynamically, so they have the same base (custom) modules, as efficient as possible.



Be able to communicate with stdout/stdin/stderr of these scripts process while it is still running.



Ideally I'd want one process to open with a docker, import my modules, and then collect the code itself to run, run it in the same process as the one already opened so it won't have to open another process nor import again my modules.



The problem: - Setting up PS process in a docker container takes tremendous amount of time. (Roughly 2.5s, before I have even begun to run any code, and I'm talking about the PS process alone)



As of yet I did not find a PS way to run dynamic code on the same process without creating a new process & importing my modules again. Nor did I find a way to dynamically communicate with the new process while it still runs.
Possible Solutions: - Create the initial PS process with -noprofile so it won't load so slowly. (I am yet to test this, but folks on redit seems to be approving of this method) - Use start-process with -NoNewWindow flag, so it will generate new process each time but I guess the initial setup time will be spared. - Trying to use Invoke-Expression on big chunks of code, but from what I understand that is not recommended and probably won't let actively communicate with the code running there until it finishes.



And

Invoke-Expression```
Are the only relevant mechanisms I could find so far.

I've been told AWS lambda features similar functionality as what I am trying to achieve, but looking at it's code I did not make much progress, figured might be worth asking for help from people who are smarter then me :) Any help would be much appreciated. I do not seek for already fully working 3ed side solution, simply being able to mimic that behavior in PS code would be good enough for me.









share|improve this question







New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm researching these days on how to can I keep a powershell process alive so I can run PS code without opening a new process each time.



The need: - Running multiple PS scripts dynamically, so they have the same base (custom) modules, as efficient as possible.



Be able to communicate with stdout/stdin/stderr of these scripts process while it is still running.



Ideally I'd want one process to open with a docker, import my modules, and then collect the code itself to run, run it in the same process as the one already opened so it won't have to open another process nor import again my modules.



The problem: - Setting up PS process in a docker container takes tremendous amount of time. (Roughly 2.5s, before I have even begun to run any code, and I'm talking about the PS process alone)



As of yet I did not find a PS way to run dynamic code on the same process without creating a new process & importing my modules again. Nor did I find a way to dynamically communicate with the new process while it still runs.
Possible Solutions: - Create the initial PS process with -noprofile so it won't load so slowly. (I am yet to test this, but folks on redit seems to be approving of this method) - Use start-process with -NoNewWindow flag, so it will generate new process each time but I guess the initial setup time will be spared. - Trying to use Invoke-Expression on big chunks of code, but from what I understand that is not recommended and probably won't let actively communicate with the code running there until it finishes.



And

Invoke-Expression```
Are the only relevant mechanisms I could find so far.

I've been told AWS lambda features similar functionality as what I am trying to achieve, but looking at it's code I did not make much progress, figured might be worth asking for help from people who are smarter then me :) Any help would be much appreciated. I do not seek for already fully working 3ed side solution, simply being able to mimic that behavior in PS code would be good enough for me.






powershell powershell-core






share|improve this question







New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Yarden SadeYarden Sade

1




1




New contributor




Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Yarden Sade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Why do you need to communicate with stdout/stdin/stderr of PowerShell host process? Does your scripts interacts with them explicitly?

    – PetSerAl
    21 hours ago











  • Yes, they should pass information in real time between them.

    – Yarden Sade
    12 hours ago



















  • Why do you need to communicate with stdout/stdin/stderr of PowerShell host process? Does your scripts interacts with them explicitly?

    – PetSerAl
    21 hours ago











  • Yes, they should pass information in real time between them.

    – Yarden Sade
    12 hours ago

















Why do you need to communicate with stdout/stdin/stderr of PowerShell host process? Does your scripts interacts with them explicitly?

– PetSerAl
21 hours ago





Why do you need to communicate with stdout/stdin/stderr of PowerShell host process? Does your scripts interacts with them explicitly?

– PetSerAl
21 hours ago













Yes, they should pass information in real time between them.

– Yarden Sade
12 hours ago





Yes, they should pass information in real time between them.

– Yarden Sade
12 hours ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Yarden Sade is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1425424%2fhow-to-keep-powershell-process-open-with-input-output-on-runtime%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Yarden Sade is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Yarden Sade is a new contributor. Be nice, and check out our Code of Conduct.













Yarden Sade is a new contributor. Be nice, and check out our Code of Conduct.












Yarden Sade is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1425424%2fhow-to-keep-powershell-process-open-with-input-output-on-runtime%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...