Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex to match all mailbox that begin with A-H 1

Status
Not open for further replies.

58sniper

MIS
Apr 25, 2004
9,152
US
I've never been good at regex. What I'm trying to do is a "Get-Mailbox" where the UserName property begins with the letters A-H. From there, I can move those mailboxes to a specific database.

Has anyone done this that can share an example? I'm trying to do something like:

Code:
Get-Mailbox -ResultSize Unlimited | ? <regex goes here> | Move-Mailbox -database "myserver\mysg\myA-Hdatabase"


Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
To match something that begins with A-H would be something like

Code:
^[A-H]

I guess in powershell it would be something like
xxx -match "^[A-H]"

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
That seems to work....

Code:
Get-Mailbox -ResultSize Unlimited | ? {$_.DisplayName -match "^[A-H]"} | Move-Mailbox -database "myserver\mysg\myA-Hdatabase"

Cool - thanks. A star for you.

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top