1
您好我有像如何顯示通過C#cmdlet和.ps1xml文件嵌套物體插入的powershell
public class Department
{
public Guid ID {get; set;}
public string Name{get; set;}
}
public class Employee
{
public Guid ID {get; set;}
public string Name{get; set;}
public Department Department {get;set;}
}
我已經創建了一個formatedoutput.ps1xml文件以顯示僱員對象中的powershell heirarchial對象結構
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>EmpView</Name>
<ViewSelectedBy>
<TypeName>Employee</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>ID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Department.Name</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
我已經註冊使用以下cmdlet我的XML文件中的PS
update-formatdata -prependpath c:\formatedoutput.ps1xml
它我顯示錶格輸出,它顯示員工ID和姓名,但不顯示部門名稱。
我認爲它是因爲它在嵌套的對象
任何人都可以請幫我在顯示部門名稱