Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How to search domain list CSV file line by line for AD User

$
0
0

Hello,

I am writing a script that will read the contents of the file for all known domains, and report if a user exists on a particular domain in the domain list CSV file.  So far, I am able to read the CSV, which shows all contents, but when I try to impose "Foreach-Object" it still only get the default domain I am on, and not the domains listed in the file. 

Any assistance would be greatly appreciated. 

$DomainList = Import-Csv "C:\Scripts\KnownDomains.csv"

$User = '<Username>'

FOREACH ($Domain in $domainlist) {
$Domain.NTDomain
$Domain.DNSDomain
$Domain.BU
}

ForEach-Object {Get-QADUser -Identity $User -Credential $admin} | select name,NTAccountName,dn


Viewing all articles
Browse latest Browse all 6937

Trending Articles