在我的结果中添加另一个属性

时间:2016-03-24 13:59:00

标签: active-directory powershell-v4.0

我该如何改变:

Search-ADAccount -AccountExpiring -UsersOnly -TimeSpan 14.00:00:00 |
  Get-ADUser -Properties Manager,AccountExpirationDate,LastLogonDate,Givenname |
  Select-Object Name, Givenname, AccountExpirationDate, LastLogonDate,
                SamAccountName, @{Name="Manager";Expression={
                  $_.Manager | Get-ADUser -Properties emailaddress |
                    Select-Object -ExpandProperty emailaddress
                }}

这样我就可以得到经理的#34;"名字也是?我试着添加:

@{Name="Manager";Expression={
  $_.Manager | Get-Aduser -properties GivenName |
    Select-Object -ExpandProperty GivenName
}

但脚本提示我输入。我无法弄清楚为什么会这样:

Search-ADAccount -AccountExpiring -UsersOnly -TimeSpan 14.00:00:00 |
  Get-ADUser -Properties Manager, AccountExpirationDate, LastLogonDate, Givenname |
  Select-Object Name, Givenname, AccountExpirationDate, LastLogonDate,
                SamAccountName, @{Name="Manager";Expression={
                  $_.Manager | Get-Aduser -Properties emailaddress |
                    Select-Object -ExpandProperty emailaddress
                }, @{Name="GivenName";Expression={
                  $_.Manager | Get-Aduser -Properties GivenName |
                    Select-Object -ExpandProperty GivenName
                }}

0 个答案:

没有答案