Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell从AD中的多个ou中选择特定的子ou_Powershell_Active Directory - Fatal编程技术网

如何使用Powershell从AD中的多个ou中选择特定的子ou

如何使用Powershell从AD中的多个ou中选择特定的子ou,powershell,active-directory,Powershell,Active Directory,我试图从一个特定的子文件夹中提取一个所有用户的列表,这个子文件夹是许多其他Ou中常见的。比如说 Get-ADUser -SearchBase "OU=Platform,OU=DeltaV,DC=RootDomain,DC=com" -Filter * 以及: "OU=Platform,OU=RootV,DC=ChildDomain,DC=RootDomain,DC=com" 大致如下: Get-ADUser -SearchBase "OU=Platform,

我试图从一个特定的子文件夹中提取一个所有用户的列表,这个子文件夹是许多其他Ou中常见的。比如说

     Get-ADUser -SearchBase "OU=Platform,OU=DeltaV,DC=RootDomain,DC=com" -Filter *   
以及:

    "OU=Platform,OU=RootV,DC=ChildDomain,DC=RootDomain,DC=com"
大致如下:

     Get-ADUser -SearchBase "OU=Platform,OU=*,DC=ROotDomain,DC=com" -Filter *
我不确定在没有为每个位置指定一个大脚本的情况下,是否可以使用PowerShell实现这一点

有什么想法吗


谢谢。

与EBGreen合作,我找到了答案:

一个简单的查询:

   Get-ADUser -filter * -Properties *  | where-object {$_ -like  "*OU=Platform*" } | select mailNickname, l, DistinguishedName | export-CSV -path "c:\workspace\Pull.csv"

这使我能够拉动所有广告,使用where对象缩小OU到平台的范围,然后选择相关数据

即使你的例子也不会产生你想要的结果。它与DC=winmain和DC=RootDomain都不匹配。对不起,我没有仔细查看。我会修改它。你的例子仍然没有多大意义。您说您希望能够在OU上放置通配符,但让它知道它仍然需要检查其他cild DC?在这种情况下,只需将搜索根设置为要查看的顶级域,然后在输出上使用Where对象过滤器来查找OU=Platform。谢谢你的帮助。很高兴你把它整理好了。你应该发布答案或者删除这个问题。我希望你意识到,这只是拉用户帐户。否则,我也可能建议您搜索“*OU=Platform,OU=*”,这样,如果您有类似于OU的“Platforms decommissioned”,它就不会错误匹配。