Run New-PSSession within Powershell Process (user logged off) from task manager

sorry if someone already asked this... We're currently setting up some scripts for managing docker container. Because we want our colleagues to submit an application for creating a container we need some automatic processes in the background. So I came up with somthing that doesn't work quite as well as it should:

There are 3 scripts involved.

The first one to fetch all applications.

It runs the following piece of code:

Start-Process powershell -LoadUserProfile -Credential $Credential -ArgumentList "-Command C:\Users\xyz\script2.ps1 -path $root" 

script2.ps1:

Runs a CmdLet from the BcContainerHelper-Package which creates the container. Somewhere between the lines it runs

New-PSSession -session .... 

to connect to the container an run some commands.

But when I run the first script via a task over the task scheduler when the user is logged off i get an error which contains the following message:

**Terminating Error(New-PSSession) **

Seems like Powershell isn't able to create a remote connection. Has that something to do with privileges?

I need to get this to work! Has someone an idea why this isn't working?

1 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like