I’m struggling with reading content from a file and then using that content to act as the input to a query of Active Directory.
Any help would be greatly appreciated, I am more than wet behind the ears.
My input file is formatted as single entry and CRLF. yes there are spaces\blanks in the file (as seen below)
The blanks are going to cause a problem for you. If those are unavoidable, you’re probably going to have to go with a more script-like approach that can test for that.
foreach ($line in (Get-Content input.txt)) {
if ($line.trim() -ne '') {
Get-ADUser ...
}
}
Your other problem (and the reason for the error) is that Get-ADUser doesn’t have a -samAcountName parameter. It’s -samAccountName - you missed a “c.”
I changed the property to sAMAccountName (typos, what a rookie) and I still error out as initially shown.
Also, you’ve written Get-ADUser …. I’m not sure what that means, perhaps an escape character issue with posting to wordpress??
[i]Get-ADUser : A parameter cannot be found that matches parameter name ‘samAccountname’.
At line:2 char:80
Turns out there’s no -samAccountName parameter at all :). You’re probably wanting to use -Identity, but you should review the help to be sure that’s what you’re after (since I don’t know the contents of your text file).