Formatting multiple object types in output from a function?

I'm stumped on this one, and have searched and searched for a solution 
or how-to with no luck.  Perhaps it just can't be done.  I have a 
function that may or may not return objects of multiple types.  I've 
setup the type and formatting information for each of the individual 
types in format.ps1xml files, and when only 1 type is returned by the 
function the formatting works as I would expect.

However, if two or more types are returned by the function, only the 
formatting for the first object type is applied and then the other types 
are displayed however PoSH deems appropriate.

Is it possible to have PowerShell apply the desired formatting to each 
object type in a group when multiple types are written to the output 
pipeline?

-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/1/2010 7:02:52 PM
windows.powershell 690 articles. 0 followers. Follow

25 Replies
1440 Views

Similar Articles

[PageSpeed] 2

Can you provide code here that demonstrates this using standard types where 
formatting files are provided with PowerShell?

  - Larry


On 4/1/2010 2:02 PM, Clint wrote:
> I'm stumped on this one, and have searched and searched for a solution
> or how-to with no luck. Perhaps it just can't be done. I have a function
> that may or may not return objects of multiple types. I've setup the
> type and formatting information for each of the individual types in
> format.ps1xml files, and when only 1 type is returned by the function
> the formatting works as I would expect.
>
> However, if two or more types are returned by the function, only the
> formatting for the first object type is applied and then the other types
> are displayed however PoSH deems appropriate.
>
> Is it possible to have PowerShell apply the desired formatting to each
> object type in a group when multiple types are written to the output
> pipeline?
>
0
Larry__Weiss
4/1/2010 7:09:38 PM
Re-reading the original post, I guess my question doesn't make much sense.

  - Larry

On 4/1/2010 2:09 PM, Larry__Weiss wrote:
> Can you provide code here that demonstrates this using standard types
> where formatting files are provided with PowerShell?
>
> - Larry
>
>
> On 4/1/2010 2:02 PM, Clint wrote:
>> I'm stumped on this one, and have searched and searched for a solution
>> or how-to with no luck. Perhaps it just can't be done. I have a function
>> that may or may not return objects of multiple types. I've setup the
>> type and formatting information for each of the individual types in
>> format.ps1xml files, and when only 1 type is returned by the function
>> the formatting works as I would expect.
>>
>> However, if two or more types are returned by the function, only the
>> formatting for the first object type is applied and then the other types
>> are displayed however PoSH deems appropriate.
>>
>> Is it possible to have PowerShell apply the desired formatting to each
>> object type in a group when multiple types are written to the output
>> pipeline?
>>
0
Larry__Weiss
4/1/2010 7:53:09 PM
Sure can:

$x = "C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) }
# Looking at the objects returned
$x[0] # FileInfo object formatted normally
$x[1] # Microsoft.Win32.RegistryKey objects formatted normally
$x    # FileInfo objects will format normally, but not the reg

This represents the basic issue: how can one apply consistent formatting 
to the output of a command/script/function when it consists of 
dissimilar object types?

-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/1/2010 8:32:45 PM
No, once the decision is made by the formatter, there's no way to 
dynamically change it.

My suggestion would be to create your own custom objects from each of the 
types.

Marco

> Is it possible to have PowerShell apply the desired formatting to each 
> object type in a group when multiple types are written to the output 
> pipeline? 

0
Marco
4/1/2010 9:19:59 PM
Then add these four lines after the five original lines for emphasis!

$x[0],$x[1] = $x[1],$x[0] # swap the array values
$x[0] # Microsoft.Win32.RegistryKey objects formatted normally
$x[1] # FileInfo object formatted normally
$x # reg objects will format normally, but not the FileInfo objects

  - Larry

On 4/1/2010 3:32 PM, Clint wrote:
> Sure can:
>
> $x = "C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) }
> # Looking at the objects returned
> $x[0] # FileInfo object formatted normally
> $x[1] # Microsoft.Win32.RegistryKey objects formatted normally
> $x # FileInfo objects will format normally, but not the reg
>
> This represents the basic issue: how can one apply consistent formatting
> to the output of a command/script/function when it consists of
> dissimilar object types?
>
0
Larry__Weiss
4/1/2010 9:39:31 PM
On 4/1/2010 2:19 PM, Marco Shaw [MVP] wrote:
> No, once the decision is made by the formatter, there's no way to
> dynamically change it.
>
> My suggestion would be to create your own custom objects from each of
> the types.

Well, that's what I've done, the objects are PSCustomObjects with 
extended type names & formatting already.

Hmm, this works for the example and my custom objects:

PS> "C:\","hklm:\software\microsoft\windows" | % { gci $_ } | group 
pstypenames | % { $_.group | Format-Table }

Thoughts?
-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/1/2010 9:39:47 PM
There is a distinct grouping of Directory objects from File objects that is not 
in the default formatting when you do it that way you posted.

   "C:\","hklm:\software\microsoft\windows" | % { gci $_ | Out-Default}

gets you the default formatting for both types.

  - Larry


On 4/1/2010 4:39 PM, Clint wrote:
> On 4/1/2010 2:19 PM, Marco Shaw [MVP] wrote:
>> No, once the decision is made by the formatter, there's no way to
>> dynamically change it.
>>
>> My suggestion would be to create your own custom objects from each of
>> the types.
>
> Well, that's what I've done, the objects are PSCustomObjects with
> extended type names & formatting already.
>
> Hmm, this works for the example and my custom objects:
>
> PS> "C:\","hklm:\software\microsoft\windows" | % { gci $_ } | group
> pstypenames | % { $_.group | Format-Table }
>
> Thoughts?
0
Larry__Weiss
4/1/2010 9:56:42 PM
On 4/1/2010 2:39 PM, Larry__Weiss wrote:
> Then add these four lines after the five original lines for emphasis!
>
> $x[0],$x[1] = $x[1],$x[0] # swap the array values
> $x[0] # Microsoft.Win32.RegistryKey objects formatted normally
> $x[1] # FileInfo object formatted normally
> $x # reg objects will format normally, but not the FileInfo objects
>
> - Larry

Exactly.  Using the array is just an example, as it could be the 
collection (or stream) of objects from a script/function/cmdlet.  The 
closest I've come is:

$x | group pstypenames | % { $_.group | out-default }

But, as you pointed out in a different post, this will separate the file 
and directory objects which isn't necessarily desirable.  It's better 
than not working at all, but still not quite the desired effect.

-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/1/2010 11:21:47 PM
You mean?
   $x | % { gci $_ } | group pstypenames | % { $_.group | Format-Table }

   $x | group pstypenames | % { $_.group | out-default }
doesn't work for me.

  - Larry

On 4/1/2010 6:21 PM, Clint wrote:
 > Exactly.  Using the array is just an example, as it could be the collection
 > (or stream) of objects from a script/function/cmdlet.  The closest I've come
 > is:
 > $x | group pstypenames | % { $_.group | out-default }
0
Larry__Weiss
4/1/2010 11:38:40 PM
And here's a variation that's even more puzzling at first encounter:
(at the command prompt execute this sequence of commands)

   $x = "C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) }

   $x[0];       # file objects formatted as expected
   $x[1];       # reg objects formatted as expected
   $x[0]; $x[1] # only the file objects formatted as expected

   $x[1];       # reg objects formatted as expected
   $x[0];       # file objects formatted as expected
   $x[1]; $x[0] # only the reg objects formatted as expected

 From a traditional imperative programming language perspective
you expect
    a;
    b;
to be the same as
    a; b;
but PowerShell's pipelining (even in the absence of a pipe symbol) throws
a curveball.

  - Larry

On 4/1/2010 6:38 PM, Larry__Weiss wrote:
> You mean?
> $x | % { gci $_ } | group pstypenames | % { $_.group | Format-Table }
>
> $x | group pstypenames | % { $_.group | out-default }
> doesn't work for me.
>
> - Larry
>
> On 4/1/2010 6:21 PM, Clint wrote:
>  > Exactly. Using the array is just an example, as it could be the
> collection
>  > (or stream) of objects from a script/function/cmdlet. The closest
> I've come
>  > is:
>  > $x | group pstypenames | % { $_.group | out-default }
0
Larry__Weiss
4/2/2010 12:17:56 AM
On 4/1/2010 4:38 PM, Larry__Weiss wrote:
> You mean?
> $x | % { gci $_ } | group pstypenames | % { $_.group | Format-Table }
>
> $x | group pstypenames | % { $_.group | out-default }
> doesn't work for me.

Ah, whoops.  I had omitted the unary operator for the "extra" array 
wrapper when I created $x for that example.  Instead of:

$x = "C:\","HKLM:Software\Microsoft\Windows" | % { ,(gci $_) }

which indeed causes
$x | group pstypenames |  % { $_.group | out-default }
to fail, I had done:

$y = "C:\","HKLM:Software\Microsoft\Windows" | % { gci $_ }

for which:
$y | group pstypenames | % { $_.group | out-default }
does work.

$x | % { $_ } | group pstypenames | % { $_.group | out-default }
will work for the first extra array wrapped example.
0
Clint
4/2/2010 2:34:14 AM
Huh, sure enough.  Now that really is weird.

I just read this post 
(http://blogs.msdn.com/powershell/archive/2006/04/30/586973.aspx) by 
Jeffrey again, and it sheds some light onto what's happening.

"[PowerShell] calls the engine to get the prompt but then it displays it 
and collects user input.  It then takes that input, concatenates " | 
Out-Default" and submits it to the engine for execution.  ... YES, under 
the covers every command entered in through the console host is piped to 
Out-Default. "

So, no matter what we do, everything gets piped to Out-Default.  What I 
get out of the post is that Out-Default looks at the first object coming 
down the pipe and decides how to format the entire stream based on that 
first object.  Which explains some of the behavior we're seeing.  Now, 
Get-Help Out-Default is interesting:

DESCRIPTION
     The Out-Default cmdlet sends output to the default formatter and 
the default output cmdlet. This cmdlet has no effect on the formatting 
or output of Windows PowerShell commands. It is a placeholder that lets 
you write your own Out-Default function or cmdlet.

A little searching turns up this post:
http://get-powershell.com/2008/06/25/stuffing-the-output-of-the-last-command-into-an-automatic-variable/

So, I tried it out:

function Out-Default { $input | group pstypenames | % { $_.group | 
Microsoft.PowerShell.Utility\Out-Default }
$x = "C:\","HKLM:Software\Microsoft\Windows" | % { gci $_ } # No unary 
operator
$x

     Directory: Microsoft.PowerShell.Core\FileSystem::C:\

Mode           LastWriteTime       Length Name
----           -------------       ------ ----
d-r--      4/1/2010  7:20 PM        <DIR> BegVCSharp
d----     2/25/2010  9:57 PM        <DIR> Games
d----     8/18/2009  9:19 PM        <DIR> inetpub
d----     7/13/2009  8:20 PM        <DIR> PerfLogs
d-r--      3/7/2010  9:54 PM        <DIR> Program Files
d-r--     3/26/2010  9:20 PM        <DIR> Program Files (x86)
d----      3/7/2010 10:01 PM        <DIR> temp
d-r--     8/15/2009  9:24 AM        <DIR> Users
d-r--      4/1/2010  7:20 PM        <DIR> Utils
d----     3/14/2010  8:23 PM        <DIR> Windows


     Directory: Microsoft.PowerShell.Core\FileSystem::C:\

Mode           LastWriteTime       Length Name
----           -------------       ------ ----
-a---    12/16/2009  8:31 PM         1024 .rnd


     Hive: HKEY_LOCAL_MACHINE\software\microsoft\windows

SKC  VC Name                           Property
---  -- ----                           --------
   0   2 HTML Help                      {IMTCTC.CHM, IMTCEN.CHM}
   1   0 ITStorage                      {}
   0   1 ScheduledDiagnostics           {EnabledExecution}
   1   2 Tablet PC                      {IsTabletPC, DeviceKind}
   2   0 TabletPC                       {}
   1   0 Windows Search                 {}

Not that this Out-Default function override is the best way to handle 
multiple types to be sure, but perhaps it is a start?
0
Clint
4/2/2010 3:05:58 AM
This is a multi-part message in MIME format.
--------------010206010603060001070201
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

So, I think I have something that comes pretty close to the target. 
Starting with the PSCX function get-formatdata, I edited it to read all 
the format.ps1xml files into memory at the beginning instead of every 
time it needed to look up format info.  Sped things up about 200%. (8 
second runs to 2 second runs, I think that's 200%...) Script to import 
the function is attached.

Next I wrote Out-MODefault:
function Out-MODefault
{
	$Input | group { Get-CFormatData $_.pstypenames[0] | select 
-ExpandProperty selectedBy -Unique } | % { $_.group | 
Microsoft.PowerShell.Utility\Out-Default }
}

Pretty straight-forward, instead of grouping objects by their typenames, 
it groups them by formatting information.  Then writes the groups to 
Out-Default.  I initially tried just overriding Out-Default, but it 
slowed every command down and was obnoxious.

So with these two functions we can do:

$x = "C:\","HKLM:Software\Microsoft\Windows" | % { gci $_ } #No Unary 
Wrapper
$x | Out-MODefault #Compare to $x | Out-Default :)

To get to format "parity" I suppose we'd have to write multiple object 
adaptations of all the Format-* cmdlets, but that might not be too bad.

Thoughts on this approach?

--------------010206010603060001070201
Content-Type: text/plain;
 name="Function_Get-CFormatData.ps1"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="Function_Get-CFormatData.ps1"

ZnVuY3Rpb24gR2V0LUNGb3JtYXREYXRhDQp7DQoJW0NtZGxldEJpbmRpbmcoRGVmYXVsdFBh
cmFtZXRlclNldE5hbWU9Ik5hbWUiKV0NCglwYXJhbSgNCglbUGFyYW1ldGVyKFBvc2l0aW9u
PTAsIFBhcmFtZXRlclNldE5hbWU9Ik5hbWUiKV0NCglbc3RyaW5nXQ0KCSRUeXBlTmFtZSwN
CgkNCglbUGFyYW1ldGVyKFBvc2l0aW9uPTAsIFBhcmFtZXRlclNldE5hbWU9Ik9iamVjdCIs
IFZhbHVlRnJvbVBpcGVsaW5lPSR0cnVlKV0NCglbcHNvYmplY3RdDQoJJElucHV0T2JqZWN0
LA0KCQ0KCVtQYXJh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JCQkJR2VuZXJhdGVWaWV3RGVmaW5pdGlvbiAkdHlwZU5h
bWUgJHZpZXcgJHJwYXRoDQoJCQkJCX0NCgkJCQl9DQoJCQl9DQoJCX0NCgkJDQoJfQ0KCXBy
b2Nlc3MNCgl7DQoJCWlmICgkcHNjbWRsZXQuUGFyYW1ldGVyU2V0TmFtZSAtZXEgJ05hbWUn
KQ0KCQl7DQoJCQlHZW5lcmF0ZVZpZXdEZWZpbml0aW9ucyAkVHlwZU5hbWUgIyRQYXRoDQoJ
CX0NCgkJZWxzZWlmICghJFR5cGVzU2VlblskSW5wdXRPYmplY3QuUFNPYmplY3QuVHlwZU5h
bWVzWzBdXSkNCgkJew0KCQkJaWYgKCRJbnB1dE9iamVjdCAtaXMgW3N0cmluZ10pDQoJCQl7
DQoJCQkJR2VuZXJhdGVWaWV3RGVmaW5pdGlvbnMgJElucHV0T2JqZWN0ICMkUGF0aA0KCQkJ
fQ0KCQkJZWxzZQ0KCQkJew0KCQkJCUdlbmVyYXRlVmlld0RlZmluaXRpb25zICRJbnB1dE9i
amVjdC5QU09iamVjdC5UeXBlTmFtZXNbMF0gIyRQYXRoDQoJCQl9DQoJCQkkVHlwZXNTZWVu
WyRJbnB1dE9iamVjdC5QU09iamVjdC5UeXBlTmFtZXNbMF1dID0gJHRydWUNCgkJfQ0KCX0N
Cn0=
--------------010206010603060001070201--
0
Clint
4/2/2010 5:21:05 AM
Is what PowerShell V2 does now reasonable?

Or do we need to create a bug/enhancement request to change the built-in behavior?

  - Larry


On 4/2/2010 12:21 AM, Clint Bergman wrote:
> So, I think I have something that comes pretty close to the target.
>  . . .
> Thoughts on this approach?
 >
0
Larry__Weiss
4/2/2010 5:30:48 PM
This is a multi-part message in MIME format.
--------------040501020205010803040804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Oops, it wasn't Get-FormatData, that's a standard cmdlet.  It was 
Get-ViewDefinition.  Renamed function and attached file...

--------------040501020205010803040804
Content-Type: text/plain;
 name="Function_Get-CViewDefinition.ps1"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="Function_Get-CViewDefinition.ps1"

function Get-CViewDefinition
{
	[CmdletBinding(DefaultParameterSetName="Name")]
	param(
	[Parameter(Position=0, ParameterSetName="Name")]
	[string]
	$TypeName,
	
	[Parameter(Position=0, ParameterSetName="Object", ValueFromPipeline=$true)]
	[psobject]
	$InputObject,
	
	[Parameter(Position=1)]
	[string[]]
	$Path = @("$pshome\*.ps1xml")
	)

	begin
	{
		$arrFormatFiles = @()
		$arrFormatFilePaths = @()
		gci $PsHome *.format.ps1xml | % { $x = New-Object xml.XmlDocument ; $x.Load($_.fullname) ; $arrFormatFiles += $x ; $arrFormatFilePaths += $_.fullname}
		Get-Module | Select -ExpandProperty exportedformatfiles | % { $x = New-Object xml.XmlDocument ; $x.load($_) ; $arrFormatFiles += $x ; $arrFormatFilePaths += $_}
		$TypesSeen = @{}
		
		# The functions below reference's object members that may not exist
		Set-StrictMode -Version 1.0
		
		function IsViewSelectedByTypeName($view, $typeName, $formatFile)
		{
			if ($view.ViewSelectedBy.TypeName)
			{
				foreach ($t in @($view.ViewSelectedBy.TypeName))
				{
					if ($typeName -eq $t) { return $true }
				}
				$false
			}
			elseif ($view.ViewSelectedBy.SelectionSetName)
			{
				$typeNameNodes = $formatFile.SelectNodes('/Configuration/SelectionSets/SelectionSet/Types')
				$typeNames = $typeNameNodes | foreach {$_.TypeName}
				$typeNames -contains $typeName
			}
			else
			{
				$false
			}
		}
		
		function GenerateViewDefinition($typeName, $view, $path)
		#function GenerateViewDefinition($typeName, $view)
		{
			$ViewDefinition = new-object psobject
			
			Add-Member NoteProperty Name $view.Name -Input $ViewDefinition
			Add-Member NoteProperty Path $path -Input $ViewDefinition
			Add-Member NoteProperty TypeName $typeName -Input $ViewDefinition
			$selectedBy = ""
			if ($view.ViewSelectedBy.TypeName)
			{
				$selectedBy = $view.ViewSelectedBy.TypeName
			}
			elseif ($view.ViewSelectedBy.SelectionSetName)
			{
				$selectedBy = $view.ViewSelectedBy.SelectionSetName
			}
			Add-Member NoteProperty SelectedBy $selectedBy -Input $ViewDefinition
			Add-Member NoteProperty GroupBy $view.GroupBy.PropertyName -Input $ViewDefinition
			if ($view.TableControl)
			{
				Add-Member NoteProperty Style 'Table' -Input $ViewDefinition
			}
			elseif ($view.ListControl)
			{
				Add-Member NoteProperty Style 'List' -Input $ViewDefinition
			}
			elseif ($view.WideControl)
			{
				Add-Member NoteProperty Style 'Wide' -Input $ViewDefinition
			}
			elseif ($view.CustomControl)
			{
				Add-Member NoteProperty Style 'Custom' -Input $ViewDefinition
			}
			else
			{
				Add-Member NoteProperty Style 'Unknown' -Input $ViewDefinition
			}
			
			$ViewDefinition
		}
		
		function GenerateViewDefinitions($typeName, $path)
		#function GenerateViewDefinitions($typeName)
		{
			#$rpaths = @(resolve-path $path)
			#foreach ($rpath in $rpaths)
			for ($i = 0 ; $i -lt $arrFormatFiles.count ; $i++)
			{
				#$formatFile = [xml](Get-Content $rpath)
				$formatFile = $arrFormatFiles[$i]
				$rpath		= $arrFormatFilePaths[$i]
				foreach ($view in $formatFile.Configuration.ViewDefinitions.View)
				{
					if ($typeName)
					{
						if (IsViewSelectedByTypeName $view $typeName $formatFile)
						{
							GenerateViewDefinition $typeName $view $rpath
						}
					}
					else
					{
					GenerateViewDefinition $typeName $view $rpath
					}
				}
			}
		}
		
	}
	process
	{
		if ($pscmdlet.ParameterSetName -eq 'Name')
		{
			GenerateViewDefinitions $TypeName #$Path
		}
		elseif (!$TypesSeen[$InputObject.PSObject.TypeNames[0]])
		{
			if ($InputObject -is [string])
			{
				GenerateViewDefinitions $InputObject #$Path
			}
			else
			{
				GenerateViewDefinitions $InputObject.PSObject.TypeNames[0] #$Path
			}
			$TypesSeen[$InputObject.PSObject.TypeNames[0]] = $true
		}
	}
}

--------------040501020205010803040804--
0
Clint
4/2/2010 5:39:24 PM
On 4/2/2010 10:30 AM, Larry__Weiss wrote:
> Is what PowerShell V2 does now reasonable?
>
> Or do we need to create a bug/enhancement request to change the built-in
> behavior?
>
> - Larry
Hmm, I'm not really sure on that one.  I would have to say that what 
PowerShell does now is the more practical approach as 99.9% of the time 
we're writing objects to the pipeline for display or storage we're 
writing objects of one type or type family, and so deciding on a format 
and streaming away proves much faster in almost every instance.

It's really just this edge case of writing completely dissimilar objects 
down a single pipe, which I haven't run into until now after using 
PowerShell since the Monad beta days, that brings the issue to the fore.

That said, I think having PowerShell be able to apply the formatting to 
multiple object types coming down the pipe consistently would be a 
desirable "out-of-the-box" feature, so perhaps we should create an 
enhancement request.

-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/2/2010 8:40:29 PM
On 4/2/2010 3:40 PM, Clint wrote:
> On 4/2/2010 10:30 AM, Larry__Weiss wrote:
>> Is what PowerShell V2 does now reasonable?
>> Or do we need to create a bug/enhancement request to change the built-in
>> behavior?
>>
> ... I think having PowerShell be able to apply the formatting to
> multiple object types coming down the pipe consistently would be a
> desirable "out-of-the-box" feature, so perhaps we should create an
> enhancement request.
>

Have you created an enhancement request for this at
https://connect.microsoft.com/powershell
?

If you do, please post the issue number here so I can add it to the list of 
issues I'm tracking.

Thanks!

  - Larry
0
Larry__Weiss
4/6/2010 2:37:24 PM
Feedback# 549043

https://connect.microsoft.com/PowerShell/feedback/details/549043/apply-formatting-to-multiple-dissimilar-object-types-emitted-from-the-pipeline#details

-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/6/2010 3:24:20 PM
Thanks!  I voted for both new issues.

  - Larry

On 4/6/2010 10:24 AM, Clint wrote:
> Feedback# 549043
>
> https://connect.microsoft.com/PowerShell/feedback/details/549043/apply-formatting-to-multiple-dissimilar-object-types-emitted-from-the-pipeline#details
>
>
0
Larry__Weiss
4/6/2010 3:37:22 PM
How about this solution?  (see last line)
  (Or has that been obvious all along?)

   $x = "C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) }
   $x[0] # FileInfo object formatted normally
   $x[1] # Microsoft.Win32.RegistryKey objects formatted normally
   #
   $x # FileInfo objects will format normally, but not the reg
   #
   $x | % {$_ | Out-Host} # FileInfo objects format normally, and also reg

  - Larry


On 4/1/2010 3:32 PM, Clint wrote:
> Sure can:
>
>   $x = "C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) }
>   # Looking at the objects returned
>   $x[0] # FileInfo object formatted normally
>   $x[1] # Microsoft.Win32.RegistryKey objects formatted normally
>   $x # FileInfo objects will format normally, but not the reg
>
> This represents the basic issue: how can one apply consistent formatting
> to the output of a command/script/function when it consists of
> dissimilar object types?
>
0
Larry__Weiss
4/11/2010 1:55:15 AM
On 4/10/2010 6:55 PM, Larry__Weiss wrote:
> How about this solution?  (see last line)
> (Or has that been obvious all along?)
>
> $x = "C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) }
> $x[0] # FileInfo object formatted normally
> $x[1] # Microsoft.Win32.RegistryKey objects formatted normally
> #
> $x # FileInfo objects will format normally, but not the reg
> #
> $x | % {$_ | Out-Host} # FileInfo objects format normally, and also reg
>
> - Larry

Unfortunately that solution only works if our object types are already 
segregated as they come down the pipe.  In the example of $x we've been 
working with the types are in separate array indices (I originally did 
that just to illustrate the different formatting of file/directory types 
and reg types).  Using another foreach statement breaks down when the 
pipeline stream consists of objects one by one, which is more typical of 
output from a cmdlet,function,etc. in my experience.  For example, contrast:

"C:\","hklm:\software\microsoft\windows" | % { ,(gci $_) } | % { $_ | 
Out-Host }

with

"C:\","hklm:\software\microsoft\windows" | % { gci $_ } | % { $_ | 
Out-Host }

Which is why the only workaround I've been able to come up with is 
grouping by type or by viewdefinition using the PSCX module. It's kinda 
late & the brain is a bit fuzzy, does that make sense?

-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/11/2010 3:24:36 AM
On 4/10/2010 10:24 PM, Clint B wrote:
> Which is why the only workaround I've been able to come up with is
> grouping by type or by viewdefinition using the PSCX module. It's kinda
> late & the brain is a bit fuzzy, does that make sense?
>

Let's begin again with something simple!

# Why is there a difference in the output of these two command lines?

   dir a*;dir a*
   dir a*;dir a* | out-default

# Why is there a different sort of difference in the output
#  of these two command lines?

   dir a*;dir variable:a*
   dir a*;dir variable:a* | out-default

  - Larry
0
Larry__Weiss
4/11/2010 4:04:03 PM
On 4/11/2010 11:04 AM, Larry__Weiss wrote:
> Let's begin again with something simple!
>
> # Why is there a difference in the output of these two command lines?
>
> dir a*;dir a*
> dir a*;dir a* | out-default
>
> # Why is there a different sort of difference in the output
> # of these two command lines?
>
> dir a*;dir variable:a*
> dir a*;dir variable:a* | out-default
>

Here's part of the text from

   Get-Help Out-Default

NAME
     Out-Default
SYNOPSIS
     Sends the output to the default formatter and to the default output cmdlet.
SYNTAX
     Out-Default [-InputObject <psobject>] [<CommonParameters>]
DESCRIPTION
     The Out-Default cmdlet sends output to the default formatter and the
     default output cmdlet. This cmdlet has no effect on the formatting or
     output of Windows PowerShell commands. It is a placeholder that lets
     you write your own Out-Default function or cmdlet.


But!  The examples above contradict that description, don't they?

I don't have a custom Out-Default installed.

  - Larry
0
Larry__Weiss
4/11/2010 5:56:49 PM
On 4/11/2010 12:56 PM, Larry__Weiss wrote:
> On 4/11/2010 11:04 AM, Larry__Weiss wrote:
>> Let's begin again with something simple!
>> # Why is there a difference in the output of these two command lines?
>> dir a*;dir a*
>> dir a*;dir a* | out-default
>> # Why is there a different sort of difference in the output
>> # of these two command lines?
>> dir a*;dir variable:a*
>> dir a*;dir variable:a* | out-default
>>

Even more confusing to me is this sequence

   $c = (dir C:a*)
   $v = (dir Variable:a*)
   $c;$v
   $c;$v | out-default
   $c;$v;$c
   $c;$v;$c | out-default

Is there any common theme to the output formatting demonstrated?

It seems to me that something is trying and failing in the attempt to produce 
the optimally minimum presentation when arrays of the same object type are 
involved in the data being formatted.

  - Larry


0
Larry__Weiss
4/11/2010 7:44:43 PM
 >> Let's begin again with something simple!
 >> # Why is there a difference in the output of these two command lines?
 >> dir a*;dir a*
 >> dir a*;dir a* | out-default
 >> # Why is there a different sort of difference in the output
 >> # of these two command lines?
 >> dir a*;dir variable:a*
 >> dir a*;dir variable:a* | out-default
 >>
 >
 >Even more confusing to me is this sequence
 >
 >  $c = (dir C:a*)
 >  $v = (dir Variable:a*)
 >  $c;$v
 >  $c;$v | out-default
 >  $c;$v;$c
 >  $c;$v;$c | out-default
 >
 >Is there any common theme to the output formatting demonstrated?

There is a theme, and I believe the answer lies in the PowerShell team's 
post, http://blogs.msdn.com/powershell/archive/2006/04/30/586973.aspx. 
The key is to remember that everything not explicitly piped to an Out-* 
cmdlet is piped to Out-Default.  To illustrate, let's start with the 
first example:

dir a*;dir a*
is equivalent to, or *really* is:
& { dir a*;dir a* } | Out-Default

dir a*;dir a* | Out-Default
is really:
& { dir a*;dir a* | Out-Default } | Out-Default

The subtle difference is better illustrated by:
& { dir a*; dir a* | Out-Default } | fl name
which at the risk of beating a dead horse, is really:
& { & {dir a*; dir a* | Out-Default} | fl name } | Out-Default

And oh how I wish I could attach a picture...maybe I can. 
Bugger...message too large, well I can stick it here: 
http://sites.google.com/site/outputredirectionfilehosting/Capture.JPG?attredirects=0. 
  I think that illustrates well how the first result written to the 
console host is the result of the outer 'dir a* | fl name | 
Out-Default', and the second result displayed is the result of the inner 
'dir a* | Out-Default'.  The second result is never piped to anything 
beyond the inner out-default, and thus is formatted "properly" even 
though it is different than the outer dir a* which we pipe to format-list.

So if we expand that to the second, somewhat more complex example:

$c = dir c:a*
$v = dir variable:a*

$c;$v
is the same as:
& { $c;$v } | Out-Default
which as we've noted, gets us nice jacked up output to the console. 
However the next line you write:

$c;$v | Out-Default

formats "as expected", because it's really being run as:

& { $c;$v | Out-Default } | Out-Default

So Out-Default is being run twice, once on the inner command for $v, and 
then again for the results of the statement that get piped to 
Out-Default by ...default... for $c.  Because of this the different 
objects have a chance to be formatted individually by their 
corresponding Out-Default cmdlet.  Which explains why grouping by 
typenames (or viewDefinitions) and writing each group individually to 
Out-Default works:

PS # $c;$v | group { $_.psobject.typenames[0] } | % { $_.group | 
Out-Default }


     Directory: Microsoft.PowerShell.Core\FileSystem::C:\temp


Mode           LastWriteTime       Length Name
----           -------------       ------ ----
-a---      2/5/2010  8:21 AM       134512 adm-workstations.xml
-a---    12/23/2009  9:22 AM        77082 aleks.xml
-a---     1/20/2010  8:55 AM          409 anotherGrox.xml
-a---      3/5/2010 10:09 AM       244035 aIEFunctional.zip
-a---      3/5/2010 10:17 AM       245929 Application.zip

Name                           Value
----                           -----
args                           {}
Admin                          #

Since Out-Default is called for each group, each group has a chance to 
be formatted individually.
-- 
v(^_^)~Clint
http://outputredirection.blogspot.com
0
Clint
4/14/2010 4:22:43 PM
Reply:

Similar Artilces:

Can't Select Addresses for "Send Email Statements" Function
When I try to select an email address from my Outlook address book on the "send email statements" area on the customer maintenance options window, the email does not display. I get the dialog box to select the email from my address book, but after clicking ok, the address does not display in the appropriate field (I've tried TO:, CC:, and BCC:). I'm using Windows 7 pro 64 bit and Outlook 2007. Any ideas? More info on this. Other users who are running Windows XP and Outlook 2003 can select entries from their address book and have them show up in the appropr...

Inserting comment depending on the Conditional formatting
Hi Is it possible to insert comment depending on the conditiona formatting.I mean if the color of the cell is blue the comment shown i " A " & if the color of the cell is green the comment shown is " B " similarly if the color of the cell is black the comment shown is " C . ( The color names which i had writted here r examples i dont know th real names of the colors which i have given in my spreadsheet) -- Little Maste ----------------------------------------------------------------------- Little Master's Profile: http://www.excelforum.com/member.php?acti...

Formatting Problem
I've created a blank booklet of x no. of pages with page size of h7.25" x w4.75" with 0.5" margins all around. I've been provided with material on floppies to incorporate into the booklet. The material is in the wrong font type and size and needs considerable change in other formatting. This I've done by opening the document into a WORD document of the same dimensions as stated above and tailoring the content to this WORD document. There are some centering, indents, right or left alignment. When I then try to insert this into the booklet in Publisher, s...

delimited file format issue
i get reports from (idx) a program that are delimited files. the columns are all fine but 1 and i can't figure it out. its supposed to be money and comes across as 11500. in the original program (idx) it would look like 115.00 and that is how i want it to look in excel. i tried the easy stuff like formatting and i keep getting 11500.00 or 1150.0 in my simple mind i thought it would be easy to move that decimal but its not turning out that way. i have thousands of line items so doing it one by one is not the optimum solution. any help is appreciated. excel 2003 os XP You really wa...

Can you filter or sort by a cell's formatting? #2
Can you filter or sort by the formatting of a cell - these were formatted manually and do not have conditional formatting applied to them - thanks You can even use a UserDefined Function that can return the colorindex. Chip Pearson has a nice function at: http://www.cpearson.com/excel/colors.htm Returning The ColorIndex Of A Cell If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm MalibuinthePeg wrote: > > Can you filter or sort by the formatting of a cell - these were formatted > manually and do...

Merge/Unmerge feature to not functioning
Software - Excel 2003 (11.6355.6360) SP1 I previously merged 4 rows in 4 seperate columns into 4 cells. That is, I created one larger cell comprised of 4 rows in each 1 column, of 4 columns, using Excel's merge feature. I would like to split the merged cells back into their original 4 rows but the merge functionality of the Alignment tab of the Format Cells' dialog box is grayed out. I have searched microsoft help and found an atlernative method for spliting cells - selecting the cell and using the Merge and Center button on the formatting toolbar - but it too is grayed out. I ...

Using "Avg" function on calculated field
In a report I have a calculated field as "=Nz([Total],0)/Hrs" which works fine. In the report footer I tried to get the average of the values in this column so I used "=Avg(Nz([Total],0)/Hrs) but when I run it it asks me for the value of "Hrs". Neither "hrs" nor "total" are calculated fields and no error is generated either. The output for the average is just blank. I tried =Avg(Nz([Total],0)/(Nz(Hrs,))) which did not work either. What am I missing? There's a couple of potential issues here. It sounds like Hrs is a field in the table/quer...

Do a calculation in cells with text data format
I have a few columns of cells having a mixed data format of number and text. Is it possible to convert the first row of numbers in text data format for further calculation? Your guidance to accomplish it is appreciated. Thanks, Ray Example? -- Regards, Peo Sjoblom "Ray" <NoSpam-ZQLi@GMail.com> wrote in message news:ei$Jbmy$FHA.216@TK2MSFTNGP15.phx.gbl... > I have a few columns of cells having a mixed data format of number and text. > Is it possible to convert the first row of numbers in text data format for > further calculation? Your guidance to accomplis...

multiple vendors or buying groups
Hello: I have a PO that may eventually be charged, by percentage to more that one vendor. So, they are buying a product that is say 25% to one vendor and 75% to the other. How can we do this? Any suggestions? Additional software? VB? Please let me know. -- Kate Hulit Asyma Systems Inc. ...

Supporting Multiple screen resolution
Hi How i can support multiple screen resolution with MFC? Thanks, Ritu What does this mean? Are you asking about dual monitor support? -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Ritu chawla" <rituc@momentum-tech.com> wrote in message news:u$xGo0GbDHA.2404@TK2MSFTNGP10.phx.gbl... > Hi > How i can support multiple screen resolution with MFC? > Thanks, > Ritu > > Hi i am working on an application whose GUI becomes completely visible in 1024 x 800 size only. i need to give support or 800 x 600 also. how can i do this. rgds, ritu "Ajay Kalra"...

.NET 3.5
Hello, Does anyone of you know how I can force vb.net to remove the handle of a local DLL which I used beforehand with Reflection. Here is a fragment of the code. I have a base class and a derived class. This app only knows the base class and creates an Instance of the derived class by using Reflection which works fine. The only problem I have is that the local DLL file is blocked (I can't delete it) as long as I don't close the Application Dim GetCustomModule as BaseClass Dim dll As Assembly = Assembly.LoadFrom("c:\tools\DerivedCass.dl...

Date formats, culture and globalization
Hi, ASP.NET 3.5 We are creating a 3-tier ASP.NET Web Application that needs just to understand dates as UK shortdate format (dd/MM/yyyy). It will only be used in the UK on intranet. I often come across web server and client machine that are incorrectly set up so I want to protect the app from these incorrectly set up hosts. I understand the safe date formats for passing through to the database. SQLParameters pass through a non-ambiguous format and also that 'yyyyMMdd' is also a safe format. So ignore the database side of things - I get that. At the moment all the bou...

Multiple Forest Solutions
Hi All, I have a situation where a client is dealing with 2 seperate Win2K3 forests. What type of solutions are available when there is a fully transitive trust relationship between forests and two seperate Exchange orginizations? Some of the things they want to do is share calanders between the forests, share address books, ect. Any help would be welcome! TIA Paul Identity Integration Feature Pack (IIFP) to share the address books. Inter-Organization Free/Busy Replication Tool to share free/busy. If you google them, you should be able to find scenario walkthroughs, in addition t...

=IF(NOT(ISNA(VLOOKUP Function
I am using Excel 2003 I am trying to produce a summary shett from five differnet worksheets. I am using the following function =IF(NOT(ISNA(VLOOKUP(E7,Tests!D1:Tests!S147,18,FALSE))),VLOOKUP(E7,Tests!D1:Tests!S147,18,FALSE),""). It works fine until I reach 18 and above and it returns #REF!. Does this formula not work after 17 or is there another formula that I should be using. Colin Hi, The VLOOKUP() table array cannot span across sheets. Do let us know what you are trying to do? -- Regards, Ashish Mathur Microsoft Excel MVP www.ashishmathur.com ...

Redefine field data type
Hi, I am trying to write a function in a module in MS Access 2000 that will change the data type of a field called 'Start' in table 'bo_cpm_CS01ALL'. Here is the code that I have done so far but when I run it nothing happens...no errors or changes to the table. The code finds the table and field, creates a new field called 'temp' then copys 'Start' to 'temp' then deletes 'Start' and renames 'temp'. The field 'Start' has data type dbDouble. Any help would be great!! Public Function ChangeFieldType() 'Purpose: Changes a f...

How do I increase size of text when typing?
I am using Word 2003 and with Word 2000 I could enlarge the size of the print before typing to increase to 150% but cannot find how to do this in the 2003 version. The print on the screen is now about a 10 which is too small for comfort. View | Zoom. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Sufimai" <Sufimai@discussions.microsoft.com> wrote in message news:1125090F-6AB0-404F-8B1C-E5EAF06917F8@microsoft.com... >I am using Word 2003 and with Word 2000 I could enlarge the size of the >p...

Formatting detail section w/two lines
HELP, I'm trying to create the below in a report, but when I align the "title" field below the "name" field and the "background" field is more than one line, the "title" is no longer directly underneath the name. Is there anyway to accomplish this? Name Background Title Thanks for your expertise! Sincerely, Cynteeuh A couple of things to try. 1- Size Backgroundbigger than two lines and set Can Shrik to No. 2- Combine Name and Title into a single text box and set Can Grow to Yes. =[Name] & Chr(13) & C...

multiple users...again
My wife and I have road runner cable. We each have our own email account. We want to use Outlook 2003 to read our respected emails. I've tried to configure it so that we each have our own password for outlook for privacy of email. As it stands now, when I click on the Outlook shortcut on the desktop it asks for my password. I give it and it opens up my email folder. I tried to create a folder for my wife's email. I put a password on her folder. Now when I open outlook from the shortcut on the desktop, it want's my password. The program opens and then to get to her f...

sp_columns does not return NVARCHAR data type columns
Hi, our SQL Server Version is 2000 SP4. For several days the SP "sp_columns" does not return NVARCHAR data type columns any more. I reviewd the SP "sp_columns" and it seems, that the used SP "spt_datatype_info" does not return that type any more. A second production server returns that column type. The SP "sp_columns" is used by the ODBC-Driver to determine the table columns. Any suggestions? Thanks a lot, Nils Ok, my fault, it seems that "spt_datatype_info" is a table and there is no NVARCHAR row. After insert...

center text when conditional format applied
Textbox control on Access 2007 form lost its centered alignment when conditional formatting is applied. This did not happen in previous versions of Access. I tried using format painter to apply conditional formats from a control created in an earlier version, but this failed. The control created in the earlier version then lost it's centering after saving in Access 2007. -- Roy Handy Interesting. I tried to replicate this behaviour but failed, it all worked as it should. Try revisiting your form after applying the conditional formatting and resetting the text box to center text. ...

Entire Visio page moves whenever I use the directional arrow keys instead of the object I've clicked on
Gurus, Running Visio 2003. For some reason lately, whenever I click on an object and try to move it using the right, left, or up or down arrow keys, the whole page moves instead of the object I've clicked on. This is really annoying! It didn't used to be this way. I'm not sure what I changed. I simply want the object I've highlighted to move whenever I use the arrow keys not the whole Visio page itself! -- Spin On Fri, 24 Oct 2008 17:29:14 -0400, "Spin" <Spin@invalid.com> wrote: >Gurus, > >Running Visio 2003. For some reason lately, whe...

Microsoft publisher, how do I set it to show multiple pages?
I'm trying to show more than one page in a single viewing pane. As in for the use of a banner. You'd think that'd be a simple and accesable function. I don't see it anywhere... Print preview has this function. Not sure if this is what you are asking... -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "BrickShort" <BrickShort@discussions.microsoft.com> wrote in message news:B42E0DAE-9DB6-4587-A157-3C2F5225FA02@microsoft.com... > I'...

Looking for an excel function which can mirror opposite the data
Dear sir, There are 2 data sets is assumed running in A1 down, viz.: From A1 down to A10, are showing a set of number: from 1 to 10 In the cell from B1 to B10, are showing from 10 to 1, which is decreasing from 10 to 1. My question: I want to know is there any excel formula which I can place in B1 and pick A10's number; B2 pick A9's number and etc. I know there is an easy way to do it, just type "=A10" in the cell of B1, but it is quite difficult to do it when I have more than 200 number, e.g. A1 to A200. Thanks for your advice, Wilchong -- Message posted via OfficeKB...

Switching between multiple open windows
I ran across an option to change how to switch between multiple open windows on my desktop. It was an option to choose between hovering over a window or clicking on it. Thinking that only having to hover over a window to switch to it would save time, I selecting the option to hover... big mistake as it just became a big pain in the a_ _ for me. Now I would like to change back to one-clicking to change between viewed windows but can't remember or find where the option is located. Any help will be appreciated. -- rushl On 2/03/10, rushl posted: > I ran across an opti...

Types of notebooks.
Have a PC on Vista. Looking to buy a notebook. The ads show 3 different types: 1. Notebook 2. Netbook 3. emachines. What's the difference between the three? TIA On Fri, 22 Jan 2010 20:40:22 +0800, Ben Stevenson wrote: > Have a PC on Vista. > > Looking to buy a notebook. The ads show 3 different types: > > 1. Notebook > > 2. Netbook > > 3. emachines. > > What's the difference between the three? > > TIA A 'netbook' is basically, a miniaturized laptop. Generally, it has no CD/ DVD driv...