简体   繁体   English

获取广告用户的管理员,并将其输入到表的列中

[英]Get an AD user's manager and input it into column of table

I have a .csv file that has the first and last names, as well as the email addresses of employees who've taken our security awareness training. 我有一个.csv文件,其中包含名字和姓氏,以及接受过我们的安全意识培训的员工的电子邮件地址。
I want to take the email address column and compare it to the email address in AD, then take the manager from AD and put it into the appropriate column of my table. 我想获取电子邮件地址列,并将其与AD中的电子邮件地址进行比较,然后从AD中获取经理,并将其放入表格的适当列中。

This is what I have so far: 这是我到目前为止的内容:

Import-Csv -Path "filename.csv" | 
    Select-Object "First Name",
        "Last Name",
        "Email",
        @{n="Manager";e={(Get-ADUser $_.Manager).EmailAddress}},
        "Module Status",
        "Module Status Date" | 
    Select -f 30 | 
    Format-Table

Thanks! 谢谢!

@{n="Manager";e={
    $self = Get-ADUser $_.Email -properties manager
    $manager = Get-ADUser $self.manager -properties emailAddress
    $manager.emailAddress
}

Of course you can write it shorter if you want to. 当然,您可以根据需要将其写得更短。

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

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