: powershell@lists.myitforum.com
Subject: Re: [powershell] RE: Get-ADUser and RegEx:
ATTENTION: This email came from an external source. DO NOT open attachments or
click on links from unknown senders or unexpected emails.
3 things.
1. Test it yourself! I saw:
PS O:\> "AB1234TEST" -ma
3 things.
1. Test it yourself! I saw:
PS O:\> "AB1234TEST" -match "^[A-Z]{2}[0-9]{3,6}"
True
PS O:\> "AB1234TEST" -match "^[A-Z]{2}[0-9]{3,6}$"
False
so I agree that it will match. (as always, you can use \w and \d for
characters and number. Maybe you wanted to restrict to only upper case
letters
I forgot to update one piece of the below code. I'm no longer returning all
properties. I have it only returning the additional property of 'OfficePhone':
$StdUsers = Get-ADuser -Filter {Enabled -eq $True} -Properties OfficePhone |
Where {$_.samAccountName -match "^[A-Z]{2}[0-9]{3,6}"}
From: O