Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

What happens to PSHELL after 20 seconds?

May
12,846
164
In another thread there's a discussion of PSHELL's current directory not automatically following TCC's current directory. I experimented with several aliases to get such following to happen and I kept running into the same oddity. I won't use an alias here. Take this command, for example.
Code:
*pshell /s "%@pshell[set-location '%_cwd'] echo OK"
As far as I can tell, it works the first two times it's issued in a TCC session. After that, if it's issued again within 20 seconds, it works; if issued again after more than 20 seconds, it fails (as below). Here's what I see in the two scenarios.
Code:
v:\> *pshell /s "%@pshell[set-location '%_cwd'] echo OK"
OK

v:\> *pshell /s "%@pshell[set-location '%_cwd'] echo OK"
PSHELL: System.Management.Automation.PSInvalidOperationException : The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently.

I get different, and not very consistent, results if I try to automate my testing, for example, with a DO loop executing the command after various delays.
 
When I run the following;
Code:
@setlocal
@echo off
ver
do kount = 1 to 3
  *pshell /s "%@pshell[set-location '%_cwd'] echo %_time"
  delay 25
enddo
endlocal

...it returns;
Code:
c:\users\jlc\utils>test

TCC  22.00.38 x64   Windows 7 [Version 6.1.7601]
04:48:52
04:49:17
04:49:43

On the second execution;
Code:
c:\users\jlc\utils>test

TCC  22.00.38 x64   Windows 7 [Version 6.1.7601]
PSHELL: System.Management.Automation.PSInvalidOperationException : The pipeline was not run because a pipeline is alre
ady running. Pipelines cannot be run concurrently.
04:53:08
04:53:33

If I run the following (twice) from a PowerShell command line;
Code:
$kount = 0
do
 { set-location c:\utils
   date
   start-sleep 25
 }
 
while ( ++$kount -lt 3 )

...it returns;
Code:
PS C:\utils> test.ps1
Fri Feb  9 05:06:03 EST 2018
Fri Feb  9 05:06:29 EST 2018
Fri Feb  9 05:06:54 EST 2018
PS C:\utils> test.ps1
Fri Feb  9 05:07:55 EST 2018
Fri Feb  9 05:08:20 EST 2018
Fri Feb  9 05:08:45 EST 2018

Joe
 
On my Windows 7 64-bit system, I have;
Code:
PS C:\utils> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

What version of Powershell is on your systems?

Joe
 
I have
Code:
Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.17929
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
 
@vefatica ,
I have been attempting to generate the error again, but I cannot.

I have modified the .BTM as follows;
Code:
@setlocal
@echo off
ver
do kount = 1 to 3
  *pshell /s "[System.IO.Directory]::GetFiles('\\.\\pipe\\')" > %_datetime.txt
  *pshell /s "%@pshell[set-location '%_cwd'] echo %_time"
  delay 25
enddo
endlocal

This allows me to see what pipes are currently in use on my system.

I believe the pipe in question is;
Code:
\\.\\pipe\\PSHost.131626667839524939.944.DefaultAppDomain.tcc

..filtered by doing;
Code:
ffind /t"PSHost." 2018*.txt

Joe
 
As I said, automating the test produces various (not very consistent) results, sometimes with no failures. The best way is to do it at a prompt, over and over, waiting various amounts of times.
 
I just got the latest (apparently) for Win7\32 (same as Joe's).
Code:
v:\> pshell /s $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.17929
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1



v:\> *pshell /s "%@pshell[set-location '%_cwd'] echo OK"
PSHELL: System.Management.Automation.PSInvalidOperationException : The pipeline was not run because a pi
peline is already running. Pipelines cannot be run concurrently.
 

Similar threads

Back
Top