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

Dealing with Strings in AD

$
0
0

$users=Get-Content c:\temp\ad\1.txt
$users

foreach ($userin$users) {
Get-ADUser-ldapfilter"(DisplayName=$user)"-Property samaccountname | Select-Object-Property samaccountname | out-file c:\temp\ad\users.txt-Append
}

The above code works fine.   It reads 1.txt which has the following data.   

Smith, Sam
Chan, Carol
Drake, Henry

It reads 1.txt and then writes their samAccountName to Users.txt    The issue I'm having is case sensitive.   If my data is all Upper Case then Get-ADUser fails and returns nothing.   I have a list of users provided by our HR department.  They have their own DB so the list I got is actually a CSV file and everything is in upper case.   Two question:

1.  How do I make Get-ADUser ignore case so it still works?   using -like did not work "(DisplayName -like $user)"

2.  How do I use -NoTypeInformation with Get-ADUser since it does not seem to support?  I only want the samaccoutname, not the title for each record.

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles