Solved

Filtering sAMAccountname by case in Powershell

Posted on 2014-01-14
3
508 Views
Last Modified: 2014-01-14
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!
0
Comment
Question by:anim8rs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39780014
You can only use the following operators with -Filter
"-eq" | "-le" | "-ge" | "-ne" | "-lt" | "-gt"| "-approx" | "-bor" | "-band" | "-recursivematch" | "-like" | "-notlike"

Open in new window


Try with Where-Object
Get-aduser -Filter * | ? {$_.sAMAccountname -cmatch'^[A-Z]+$'} 

Open in new window

0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39780161
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.
0
 

Author Closing Comment

by:anim8rs
ID: 39780195
Worked like a champ!  Thanks!  I had tried a variation of that, but looks like I had a problem with syntax.

Thanks a ton!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's a look at newsworthy articles and community happenings during the last month.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question