1

Why do I get different outputs if I execute the following two commands in script and on the command line?

ps
dir

Is there an automatic pipe behaviour?

Here is the output from the two commands (outputs shortened):

PS C:\Users\Robzzz> ps

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    682      73    73040      62340   423     2,31   8464 iexplore
    424      15     6332       6024    62             884 svchost

PS C:\Users\Robzzz> dir

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d-r--        23.09.2013     09:24            Contacts
d-r--        03.12.2013     15:30            Desktop

Here is the output from the script (outputs shortened):

PS C:\Users\Robzzz> .\psdir.ps1

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    682      73    73040      62340   423     2,31   8464 iexplore
    424      15     6332       6024    62             884 svchost

PSPath            : Microsoft.PowerShell.Core\FileSystem::C:\Users\Robzzz\Contacts
PSParentPath      : Microsoft.PowerShell.Core\FileSystem::C:\Users\Robzzz
PSChildName       : Contacts
PSDrive           : C
PSProvider        : Microsoft.PowerShell.Core\FileSystem
PSIsContainer     : True
Name              : Contacts
Parent            : Robzzz
Exists            : True
Root              : C:\
FullName          : C:\Users\Robzzz\Contacts
Extension         : 
CreationTime      : 02.01.2012 09:38:38
CreationTimeUtc   : 02.01.2012 08:38:38
LastAccessTime    : 02.01.2012 09:38:38
LastAccessTimeUtc : 02.01.2012 08:38:38
LastWriteTime     : 23.09.2013 09:24:09
LastWriteTimeUtc  : 23.09.2013 07:24:09
Attributes        : ReadOnly, Directory
BaseName          : Contacts
Mode              : d-r--


PSPath            : Microsoft.PowerShell.Core\FileSystem::C:\Users\Robzzz\Desktop
PSParentPath      : Microsoft.PowerShell.Core\FileSystem::C:\Users\Robzzz
PSChildName       : Desktop
PSDrive           : C
PSProvider        : Microsoft.PowerShell.Core\FileSystem
PSIsContainer     : True
Name              : Desktop
Parent            : Robzzz
Exists            : True
Root              : C:\
FullName          : C:\Users\Robzzz\Desktop
Extension         : 
CreationTime      : 02.01.2012 09:36:02
CreationTimeUtc   : 02.01.2012 08:36:02
LastAccessTime    : 03.12.2013 15:30:08
LastAccessTimeUtc : 03.12.2013 14:30:08
LastWriteTime     : 03.12.2013 15:30:08
LastWriteTimeUtc  : 03.12.2013 14:30:08
Attributes        : ReadOnly, Directory
BaseName          : Desktop
Mode              : d-r--
1
  • 1
    There shouldn't be a difference. It's hard to tell without looking at something, a sample result can help. Commented Dec 3, 2013 at 14:13

1 Answer 1

1

I agree with Shay's comment. My first guess is that it might be the host trying to resolve different kinds of output in the same format.

Here's a good post which outlines the issue (if that's it).

http://tfl09.blogspot.com/2013/11/powershells-single-formatting-pipeline.html

edit: Your updated output confirms that this is the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.