I have created a PowerShell cmdlet in C#:
using System.Management.Automation;
using thosepeskyexternalclasses
[Cmdlet(VerbsCommon.Get, "GetActivity", SupportsTransactions = false)]
public class GetActivity : PSCmdlet
{
protected override void ProcessRecord()
{
base.ProcessRecord();
// Get the activities
List<activity> activities = GetActivities();
WriteObject(activities);
}
}
The activity object does not contain a name property so when it is returned and displayed it is using the ID Value. This can be resolved by using the following command:
Update-TypeData -TypeName activity -DefaultDisplayProperty otherprop
This has to be done every time I start a new PowerShell session. Is there a way to do the equivalent function when my extension module is loaded?
*.Types.ps1xmltype-extension file with it.