Trying to get a count of AD users

I don't PowerShell enough, so each time I need to run a script my go to is Google, but I am not finding what I need.

I am running the following to get a count of user IDs and it's returning 0 count and all of our user IDs are 6-7 characters long, so know there are user IDs with 6 characters.

(Get-ADUser -Filter * -SearchBase “OU=Users,OU=Company,DC=MyDomain” | Where {$_.samaccountname.lenght -eq 6}).count

Once I can get this to run I need to add, or $_.samaccountname.length -eq 7 and I need to check that the account name starts with 2 alpha characters and 4-5 numbers.

Hope someone can help point me in the right direction.

Thanks, in advance.

Parents
No Data
Reply Children