当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 列出 Active Directory 非 LVR 组成员

作者:精品下载站 日期:2024-12-14 07:16:28 浏览:12 分类:玩电脑

列出 Active Directory 非 LVR 组成员


我的朋友 Jimmy 不久前在他的博客上写了几篇关于 Active Directory 组中非 LVR(又名旧版)组成员的文章。

您可以在这里找到他关于如何查找非 LVR 成员的帖子:http://jimmytheswede.blogspot.se/2013/06/non-lvr-groupmembers-how-to-find-them.html

有一天,当我在客户处遇到类似的情况时,我编写了这个 PowerShell 函数,用于列出组中的所有非 LVR 成员:

Function Get-NonLVRMembers {
    [CmdletBinding(HelpUri = 'http://blog.simonw.se/',
                  ConfirmImpact='Low')]
    [OutputType([String])]
    Param(
        [Parameter(Mandatory=$true,
        ValueFromPipeline=$false)]
        [ValidateNotNullOrEmpty()]
        [Alias("dc")]
        $DomainController,
        [Parameter(Mandatory=$true,
        ValueFromPipeline=$true)]
        [ValidateNotNullOrEmpty()]
        [Alias("dn")]
        $DistinguishedName
    )
    # Get meta data by running repadmin
    $ObjectMeta = & repadmin.exe /showobjmeta $DomainController "$DistinguishedName"

    # Define regular expression to find LEGACY membership
    $Regex = 'LEGACYs.*?((CN=.*?,)+?(OU=.*?,)*?(DC=.*?,)*?(DC=.*?))s'

    # Match output from repadmin with regular expression and return legacy members distinguished name
    ([regex]::matches($ObjectMeta, $Regex, @("Multiline"))) | Foreach {
        $_.Groups[1].Value
    }
}

这将返回一个字符串列表,每个字符串包含非 LVR 组成员的可分辨名称。

我使用这些信息生成了一份报告,其中显示每个组有哪些 LVR 成员以及有多少 LVR 成员。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯