Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$map = Invoke-MapDomainTrust
$domains = (($map | select -ExpandProperty sourcename) + ($map | select -ExpandProperty targetname)) | Select-Object -Unique
ForEach ($computer in (gc computers.txt | Sort-Object -Unique)) {
ForEach ($domain in $domains) {
$fqdn = Get-DomainComputer -SearchBase "GC://$domain" -LDAPFilter "(name=$computer)" -Properties dnshostname
if ($fqdn -ne $null) {
$fqdn
break
}
}
if ($fqdn -eq $null) { Write-Error "Could not find $computer in $domains" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.