阅读TXT线,由线及查询AD [英] Read txt line by line and query AD
本文介绍了阅读TXT线,由线及查询AD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含samids的文本文件:
I have a text file containing samids:
XXXXXXX
YYYYYYY
ZZZZZZZ
对于每一个我需要阅读它quering AD这一点:
For each one I need to read it quering AD with this:
dsquery user forestroot -samid XXXXXXX | dsget user -email
和写响应到另一个文件。请帮我:)
and write the response into another file. Please help me :)
推荐答案
使用 GET-ADUser便有
从的ActiveDirectory
PowerShell的模块,而不是双链工具:
Use Get-ADUser
from the ActiveDirectory
PowerShell module instead of the ds tools:
Import-Module ActiveDirectory
Get-Content 'C:\path\to\input.txt' |
Get-ADUser -SearchBase 'DC=example,DC=org' -Property mail |
select -Expand mail | Out-File 'C:\path\to\output.txt'
其中, DC =例如,DC =组织
是可分辨名称林根域(DN)。
Where DC=example,DC=org
is the distinguished name (DN) of your forest root domain.
有关编程确定可以使用此林根域的DN:
For programmatically determining the DN of the forest root domain you could use this:
([ADSI]"LDAP://RootDSE").RootDomainNamingContext
这篇关于阅读TXT线,由线及查询AD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文