querying multiple domains is it possible ?
okay,
i have script searches ad domain , return if enabled or not. work huge company have multiple ad domain names. when run script, looks @ 7 groups extracts of users when query status, see status domain, in. how able write out , possible. think possible because find users other domains.
this got far.
$adgroupmembers = get-content c:\users\jmateo\desktop\admembers.txt$test =@(foreach($adgroupmember in $adgroupmembers ){
(get-adgroupmember $adgroupmember).distinguishedname
})| out-file c:\users\jmateo\test.txt
$itgssi =select-string -path c:\users\jmateo\test.txt -pattern 'domain5'
($itgssi)-replace(".*:") | out-file c:\users\jmateo\itgssi.txt
get-content -path c:\users\jmateo\itgssi.txt |
foreach-object {
get-aduser -ldapfilter "(distinguishedname=$_)" |
select-object -property distinguishedname,enabled
}
$itginc = select-string -path c:\users\jmateo\test.txt -pattern 'domain4'
($itginc)-replace(".*:") | out-file c:\users\jmateo\itginc.txt
get-content -path c:\users\jmateo\itginc.txt |
foreach-object {
get-aduser -ldapfilter "(distinguishedname=$_)" |
select-object -property distinguishedname,enabled
}
$itgil = select-string -path c:\users\jmateo\test.txt -pattern 'domain3'
($itgil)-replace(".*:") | out-file c:\users\jmateo\itgil.txt
get-content -path c:\users\jmateo\itginc.txt |
foreach-object {
get-aduser -ldapfilter "(distinguishedname=$_)" |
select-object -property distinguishedname,enabled
}
$itgcan = select-string -path c:\users\jmateo\test.txt -pattern 'domain2'
($itgcan)-replace(".*:") | out-file c:\users\jmateo\itgcan.txt
get-content -path c:\users\jmateo\itgcan.txt |
foreach-object {
get-aduser -ldapfilter "(distinguishedname=$_)" |
select-object -property distinguishedname,enabled
}
$itgasiapac = select-string -path c:\users\jmateo\test.txt -pattern 'domain1'
($itgasiapac)-replace(".*:") | out-file c:\users\jmateo\itgasiapac.txt
get-content -path c:\users\jmateo\itgasiapac.txt |
foreach-object {
get-aduser -ldapfilter "(distinguishedname=$_)" |
select-object -property distinguishedname,enabled
}
in case it's helpful, i'll link wrote yesterday , shared on powershell.org, in regard similar type question. in person's request, had list of computers , wanted determine in domain computer resided. might able borrow wrote out. let me know if have questions. http://powershell.org/wp/forums/topic/check-if-ad-computer-is-in-on-of-many-domains/#post-33568
Windows Server > Windows PowerShell
Comments
Post a Comment