【发布时间】:2019-09-01 07:29:00
【问题描述】:
我想为每个 OU 运行相同的 Powershell 命令。 OU 列表在文本文件中给出。
**Powershell command:**
run_script OU1
run_script OU2
**Text File:**
OU1
OU2
...
到目前为止,我已经写了以下逻辑:
$OUnames = Get-Content("C:\ouNames.txt");
foreach ($OU in $OUnames)
{
$output = run_script $OU
if($output -contains "success")
// then delete $OU from ouNames.txt
// and inlcude $OU in the file ouNamesAdded.txt
}
如何在run_script $OU 返回特定OU 的success 之后从第一个文本文件中删除OU。另外,如何将$OU添加到另一个文件ouNamesAdded.txt
如何从C:\ouNames.txt 中提取多个OU,然后为多个OU 并行运行run_script $OU
【问题讨论】:
-
非常不清楚
run_script对参数$OU的作用。特别是,因为这似乎只包含名称,而不是 DistinghuishedName.. 请多解释一下并向我们展示相关代码。
标签: windows powershell powershell-2.0 powershell-3.0