简体   繁体   English

获取广告用户管理器 DisplayName output

[英]Getting ad-users Manager DisplayName output

I want to fetch the manager's user object and grab the DisplayName instead of the DN.我想获取经理的用户 object 并获取 DisplayName 而不是 DN。

$expiredaccounts = Search-ADAccount -AccountExpiring -TimeSpan 70.00:00:00 | Where-Object { ($_.Enabled -eq $true) }


$expiredaccounts | Select-Object name, SamAccountName, @{Name='EmployeeID';Expression={($_ |Get-ADUser -Properties employeeID).employeeID}} , @{Name='Manager';Expression={($_ |Get-ADUser -Properties manager).manager}}

Output: Output:

name          SamAccountName    EmployeeID Manager                                                            
----          --------------    ---------- -------                                                            
User user01                                CN=User,OU=IT,DC=contoso,DC=com

Pipe it to Get-ADUser once again: Pipe 再次将其发送到Get-ADUser

$expiredaccounts | Select-Object name, SamAccountName, @{Name='EmployeeID';Expression={($_ |Get-ADUser -Properties employeeID).employeeID}} , @{Name='Manager';Expression={ (($_ |Get-ADUser -Properties manager).manager | Get-ADUser).Name}}

Explanation :说明

You take the Manager property and run Get-ADUser against it.您获取Manager属性并针对它运行Get-ADUser It returns user object of user's manager.它返回用户经理的用户 object。 Using .Name you extract the only required property, which is display name.使用.Name可以提取唯一需要的属性,即显示名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM