![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Only the first command is is formatted I'm working on a project that hosts PowerShell scripts and I ran into a problem that I haven't been able to figure out. Only the first command in a script is formatted as expected. After that, the output is formatted as if there were no format data files (*.format.ps1xml). I found that the Host03 sample that ships with the SDK illustrates this problem. If you build and run the Host03 sample and enter: dir; get-process you will see a directory listing formatted with one line per file and then you will see a process listing but, each process is formatted like: Id : 3184 Handles : 315 CPU : 1.923 Name : procname If you enter: get-process; dir you will see a process listing formatted with one line per process and then you see a directory listing but, each file appears like: LastWriteTime : 1/1/2007 12:34 PM Length: : 100 Name : Host03.pdb Can anyone explain this? What's going on? Also, if you type: dir; dir why do you only get one directory heading? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Only the first command is is formatted I just realized that you don't even have to use the Host03 sample to illustrate this. You can just type: dir; get-process and get-process; dir at the PowerShell prompt. Why isn't the second command formatted? |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Only the first command is is formatted try these: dir |out-default; gps gps | out-default; dir What is happening is that you didn't specify a formatter so what happens is that you generated a single stream of heterogenous objects and then the SHELL sends that SINGLE stream gets sent to formatting and outputting. They way format/outputing works is that the first object in the stream is used to loopup format information. That information is then used to format the rest of the stream. If it encounters an object that isn't part of that formatting record, it does a FORMAT-list on it. In this example, I fake up a heterogenous array of objects and emit them for formatting to show how this is working. You can control when to start a NEW formating stream by being explicit with your formatting (e.g. piping to out-default) PS> $x= (dir)[0],(gps)[0],(dir)[1],(gps)[1] PS> $x Directory: Microsoft.PowerShell.Core\FileSystem::C:\ps Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 11/21/2006 2:33 PM jobs Id : 6340 Handles : 232 CPU : 21.140625 Name : AcroRd32 d---- 11/21/2006 2:33 PM PhotoLibrary Binaries Id : 3396 Handles : 73 CPU : Name : alg -- Jeffrey Snover [MSFT] Windows PowerShell Architect Microsoft Corporation This posting is provided "AS IS" with no warranties, no confers rights. |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Only the first command is is formatted Thanks, I understand what's going on now. It's not what I would expect, when a script is being executed, I would expect the first line to be completed before the second line is started. But, the more I think about it, the more I like it. |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cannot e mail a picture because it is not formatted? | aura10 | Vista music pictures video | 1 | 06-20-2008 03:17 AM |
| Help, please. DVD-RW thinks every disc needs to be formatted | qbit | General Discussion | 4 | 05-31-2008 06:21 AM |
| Problems with a formatted drive | Demons77 | Vista performance & maintenance | 1 | 11-15-2007 05:45 AM |
| formatted vista hd in rage and .... | bigger brother | Vista installation & setup | 5 | 06-24-2007 10:23 AM |
| just formatted my PC and can't re-activate | tingly | Vista installation & setup | 7 | 05-19-2007 07:18 AM |