Powershell脚本,用于在AD上搜索有限数量的用户的属性

时间:2016-03-02 14:46:22

标签: powershell

我正在尝试运行有限数量用户的PS脚本。因为我在AD上有太多用户,所以需要很长时间。

任何人都知道如何在有限数量的用户上运行脚本? 例如: 200

2 个答案:

答案 0 :(得分:0)

将用户存储在变量中,根据需要循环显示:

from itertools import izip, tee, count

def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)




def pairs(l, inds):
    st = set(inds)
    pr, cn = pairwise(l), count(0)
    prev = 0
    for a, b in pr:
        i = next(cn)
        if i not in st:
            if i - 1 != prev:
                yield a
            yield b
            next(pr)
            prev = i

现在增加$user = Get-ADUser -Filter "*" $start = 0; for ($i = $start; $i -lt $start + 200; $i++) { $user[$i] # run your code here } 然后再去。

答案 1 :(得分:0)

您可以使用-ResultSetSize参数限制返回的用户数:

Get-ADUser -Filter * -ResultSetSize 200
相关问题