2015-07-16 209 views
0

嗨,我想知道我的廣告組名爲BIDEV的位置在我的廣告內,如下圖所示。如何在活動目錄中搜索組名?

它存在,但它在哪裏?

此外,我可以如何使用Powershell做到這一點的任何示例?

enter image description here

enter image description here

+1

你看着[獲取-ADGROUP](HTTPS ://technet.micro soft.com/en-us/library/ee617196.aspx)? – Kin

回答

0
#------------------------------ 
# 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" 

enter image description here

+0

腳本的第一部分我尋找用戶mmartin –

+0

腳本的第二部分我查找名稱包含BIDEV的AD組。我以爲我只有一個,我添加了圖片的結果 –