Reputation: 11
When I run Get-Recipient | ft Name
in the console everything looks good,
but when I try it in a script the output is just a list of class names;
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
How do I fix this? Thankful for any and all help!
//David
Upvotes: 1
Views: 142
Reputation: 16802
The Format-*
cmdlets should only be used to control display of data. They should rarely if ever be used inside "library" type scripts or functions, expect maybe when displaying status messages or something. The actual output of a Format-*
cmdlet is a bunch of magic objects (the FormatEntryData
guys) that direct the Powershell engine on how to do display formatting.
It works in the console because you are not capturing your data, you are just letting it display to the screen.
In your script, you should just return the data as-is, and let the caller decide how to format it, if (s)he wants to. If you want to return back only the Name
field, use Select-Object Name
to pare away the other fields.
Upvotes: 5