Link to home
Start Free TrialLog in
Avatar of anim8rs
anim8rsFlag for United States of America

asked on

Filtering sAMAccountname by case in Powershell

So I have been beating my head against a wall trying to figure this one out.

I need to run a script that will return to me any sAMAccountname in AD that is in all uppercase.  I believe that this is getting closer, but the operator is not supported...

get-aduser -Filter {sAMAccountname -cmatch'^[A-Z]+$'} -Properties name,samaccountname

Any input?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Of course you could also use
Get-aduser -Filter * | ? {$_.sAMAccountname -ceq $_.sAMAccountname.ToUpper() } 

Open in new window

but that doesn't change anything. Major issue is that the check has to happen on the client, and no cmdlet filter expression can be used.
Avatar of anim8rs

ASKER

Worked like a champ!  Thanks!  I had tried a variation of that, but looks like I had a problem with syntax.

Thanks a ton!