Read txt line by line and query AD

后端 未结 2 469
太阳男子
太阳男子 2021-01-26 11:42

I have a text file containing samids:

XXXXXXX
YYYYYYY
ZZZZZZZ

For each one I need to read it quering AD with this:

dsquery user         


        
2条回答
  •  抹茶落季
    2021-01-26 12:40

    Finally, I managed to solve it this way proposed on the other post:

    $a = Get-Content .\input.txt 
    for ($i=0 ; $i -lt $a.Length; $i++){
     dsquery user forestroot -samid $a[$i] | dsget user -email | Select-String '@' | select -Expand Line >> output.txt
    }
    

    Thank you

提交回复
热议问题