[英]how to search for a group name within the active directory?
Hi I would like to find out where my AD group called BIDEV is located within my AD, as you can see on the pictures below. 嗨,我想找出我名为ADDEV的广告组位于广告中的位置,如下面的图片所示。
It exists, but where is it? 它存在,但是在哪里?
Also, any example of how I could do this using Powershell? 另外,关于如何使用Powershell进行此操作的任何示例?
Maybe this will help you, here a link 也许这会对您有所帮助,请点击此处
http://www.indented.co.uk/2008/12/08/returning-the-ou-for-an-object/ http://www.indented.co.uk/2008/12/08/returning-the-ou-for-an-object/
#------------------------------
# first part search for a user
#------------------------------
Clear-Host
$SearchFor = "mmartin"
import-module activedirectory
Write-Host "Searching..."
$all_users_list=Get-ADUser -filter * -properties SamAccountName,sn,GivenName,mail,EmailAddress,LastLogonDate,Country,DistinguishedName,CanonicalName |
select-object SamAccountName,sn,GivenName,mail,EmailAddress,LastLogonDate,Country,DistinguishedName,CanonicalName -ErrorAction silentlycontinue
foreach($u in $all_users_list)
{
if($u.SamAccountName -like "*$SearchFor*")
{
$Output = $u.SamAccountName + " - " + $u.DistinguishedName
Write-Host $Output
}
}
Write-Host "Done"
#that will work
#just put what you want at the top in "SearchFor"
#mmartin my powershell guru - 16-july-2015
#------------------------------
# second part search for a group
#------------------------------
Clear-Host
$SearchFor = "BIDEV"
import-module activedirectory
Write-Host "Searching..."
$all_group_list=Get-ADGroup -filter * -properties * |
select-object * -ErrorAction silentlycontinue
foreach($u in $all_group_list)
{
if($u.SamAccountName -like "*$SearchFor*")
{
$Output = $u.SamAccountName + " - " + $u.DistinguishedName
Write-Host $Output
}
}
Write-Host "Done"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.