Powershell Active Directory 类似过滤器如何工作?

标签 powershell active-directory

你好,我只是不明白类似的东西在 powershell 中是如何工作的。

这一行给出 1 条记录:

Get-ADGroup -Filter {DistinguishedName -eq "CN=Development,CN=Users,DC=mycompany,DC=it"}

但是这个:

Get-ADGroup -Filter {DistinguishedName -like "*Development*"}

不返回任何内容。这是怎么回事?

最佳答案

可分辨名称不能与 LDAP 进行通配符匹配,-Filter 将在内部将其转换为通配符。

这就是为什么您看不到任何结果

您可以检索名称中包含“Development”的所有 OU 并搜索所有这些:

$ADGroups = @()
$DevOUs = Get-ADOrganizationalUnit -Filter {name -like "*ex*"}| Select-Object DistinguishedName

foreach($ou in $DevOUs)
{
    $DN = $ou.DistinguishedName
    foreach($Group in (Get-ADGroup -SearchBase $DN))
    {
        # Prevent duplicates
        if($ADGroups -notcontains $Group)
        { $ADGroups += $Group }
    }
}

关于Powershell Active Directory 类似过滤器如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25443474/

相关文章:

使用 xPath .SelectSingleNode 的 Powershell 脚本无法从 web.config 文件 xmlns 中提取值

powershell - 在 Powershell 中自动将数字添加到变量中

c# - 在 Visual Studio 中运行 PowerShell 脚本时无法获取 Active Directory 终端服务属性

C# ActiveDirectory - 检查对象类

powershell - 在Get-ADComputer中排序

sorting - "MMdd"中的昨天日期,具体的输出文件夹选择取决于日期

html - 使用 HTML 表单作为 powershell 的 GUI

php ldap 搜索 : no such object

powershell - 如何在PowerShell中从数组创建ArrayList?

powershell - 如何在PowerShell中仅从Measure-Object返回整数?