简体   繁体   中英

Powershell variable passing inline

get-content C:\OUlist.txt | get-qadcomputer -SearchRoot $_ -DontUseDefaultIncludedProperties -IncludedProperties info

In the OUlist.txt file there is a list of OUs. I am having trouble passing each of the OUs to the get-qadcomputer command. If I hard code the OU in the command using 'company.com\\workstation\\Win7' instead of the "$_" the script runs fine.

Is there something that I am doing incorrectly to with regard to passing the OU down the pipeline?

-SearchRoot参数不接受管道输入,因此您需要使用循环:

get-content C:\OUlist.txt | ForEach-Object { get-qadcomputer -SearchRoot $_ -DontUseDefaultIncludedProperties -IncludedProperties info }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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