I used this article to write my first own Powershell Cmdlet and Snapin. And it works fine.
But I return a set of objects from my own data class, which has four properties and I want Powershell to display just one of these properties by default. So I used this part of the article to create this format file:
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>RemoteFile</Name>
<ViewSelectedBy>
<TypeName>MyFullNamespace.RemoteFileData</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader />
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Filename</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
and link it in the Snapin:
public override string[] Formats
{
get { return new string[] { "MyFormatFilename.ps1xml" }; }
}
But when I install the Snapin with installutil, use Add-PSSnapin and call my Cmdlet, all Properties of the objects are displayed.
What am I doing wrong?