Sunday, 26 January 2014

List of Users in Multiple Domain..

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.



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"
}
}
}
view raw gistfile1.ps1 hosted with ❤ by GitHub

No comments:

Post a Comment

ServiceNow onboarding Sailpoint