获取电子邮件 AD 属性 以匹配给定广告用户名列表
Get the email AD property to match with a list of given ad usernames
我得到了一个文本文件中的广告用户名列表,需要一个脚本来使用用户名并将它们与广告配置文件匹配,从用户广告配置文件中获取电子邮件,然后使用 CSV 2 导出列用户名和电子邮件地址。到目前为止,脚本导出了电子邮件,但我希望在下一列中导出 adusername。
Get-Content C:\Users\xxx\Downloads\Users.txt |
forEach { Get-ADUser $_ -Properties EmailAddress } |
select -ExpandProperty EmailAddress |
Out-File C:\Output\userslists.csv
如果您想将一些数据导出到 CSV 文件,您应该使用专门为此设计的正确 cmdlet。如果你想输出 Name 或 sAMAccountName 或任何你只需要用 Select-Object cmdlet 告诉它:
Get-Content C:\Users\xxx\Downloads\Users.txt |
Get-ADUser -properties EmailAddress |
Select-Object -Property Name,sAMAccountName,EmailAddress |
Export-Csv -Path 'C:\Output\userslists.csv' -NoTypeInformation
我得到了一个文本文件中的广告用户名列表,需要一个脚本来使用用户名并将它们与广告配置文件匹配,从用户广告配置文件中获取电子邮件,然后使用 CSV 2 导出列用户名和电子邮件地址。到目前为止,脚本导出了电子邮件,但我希望在下一列中导出 adusername。
Get-Content C:\Users\xxx\Downloads\Users.txt |
forEach { Get-ADUser $_ -Properties EmailAddress } |
select -ExpandProperty EmailAddress |
Out-File C:\Output\userslists.csv
如果您想将一些数据导出到 CSV 文件,您应该使用专门为此设计的正确 cmdlet。如果你想输出 Name 或 sAMAccountName 或任何你只需要用 Select-Object cmdlet 告诉它:
Get-Content C:\Users\xxx\Downloads\Users.txt |
Get-ADUser -properties EmailAddress |
Select-Object -Property Name,sAMAccountName,EmailAddress |
Export-Csv -Path 'C:\Output\userslists.csv' -NoTypeInformation