Solved

Regex Select user names with X.

Posted on 2014-12-01
8
121 Views
Last Modified: 2014-12-01
User names consist of a-z upper and lower case followed by 6 digits. Example. A123456 or B459087 or U997345.
I have a list that contains other names like Administrator or JoeSmith other than the users names above.
I would like to only see the User names "[a-z]123456".
0
Comment
Question by:Xytras1
8 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40474059
What is your question?
0
 

Author Comment

by:Xytras1
ID: 40474068
Opps should of said a little more.

I have a List of User names  that consist of a-z upper and lower case followed by 6 digits. Example. A123456 or B459087 or U997345. Also the list that contains other names like Administrator or JoeSmith other than the users names above.
I would like to only see the User names "[a-z]123456".
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40474074
I still don't see a question   : \

Are you asking what the pattern that would match the above should be, or are you asking how to do a regex search in PowerShell, or are you asking something else?
0
 
LVL 39

Assisted Solution

by:footech
footech earned 250 total points
ID: 40474078
Perhaps you're trying to read from a file and want to only display names that match your criteria?
get-content file.txt | Where { $_ -match "[a-z][0-9]{6}" }

Open in new window

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Xytras1
ID: 40474081
This should help with my poor English sorry.

$OldList =  "A123456, B459087, U997345, JoeSmith, Administrator"

$NewList = "A123456, B459087, U997345"

Trying to filter out non standard user names.
0
 

Author Comment

by:Xytras1
ID: 40474091
footech.

get-content file.txt | Where { $_ -match "[a-z][0-9]{6}" }

Is pretty close. Any way to make it match exactly?
Getting some false positives like "CPAOLAM3334988"
0
 
LVL 83

Accepted Solution

by:
oBdA earned 250 total points
ID: 40474109
You need to anchor the match: "^[a-z]\d{6}$"
0
 

Author Closing Comment

by:Xytras1
ID: 40474117
"^[a-z]\d{6}$" Works. Thank you.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A procedure for exporting installed hotfix details of remote computers using powershell
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now