How to find user in multiple domain, PowerShell by default will point to parent domain and will not fetch the result in child domain.When u will get list of users containing both parent and Child domain,PowerShell will not fetch the result for child domain.
The below is the Script which will point to both domain.
The below is the Script which will point to both domain.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module ActiveDirectory | |
$erroractionpreference = “SilentlyContinue” | |
# Declaring variable | |
$a = Get-content "path of the txt file" | |
foreach($i in $a) | |
{ | |
Get-ADuser -identity $x # Parent domain | |
If(!$?) | |
{ | |
try { | |
Get-Aduser -identity $x -server Domain1 | |
} | |
catch | |
{ | |
Write-Host "The user is not found in parent and child domain" | |
} | |
} | |
} |