我有以下代码块来输出两列数据,标题为Name:
和Members Of:
:
Get-ADUser -Filter 'Name -Like "UAT*"' -Properties Name, MemberOf |
Select-Object @{N="Name:";E = {Name}}, @{N="Members Of:"; E ={$_.MemberOf -replace '\w+=' -join "; "}}
但是,当我运行此选项时,只有Members of:
列,Name:
列完全空白。如何使用自定义标题填充两列?
答案 0 :(得分:2)
您需要使用管道对象Name
访问属性$_.Name
,而不仅仅是Name
:
Get-ADUser -Filter 'Name -Like "UAT*"' -Properties Name, MemberOf |
Select-Object @{N="Name:";E = {$_.Name}}, @{N="Members Of:"; E ={$_.MemberOf -replace '\w+=' -join "; "}}