PowerShell 技能连载 - Getting AD Users with Selected First Letters
How would you query for all AD users with names that start with a “e”-“g”? You shouldn’t use a client-side filter such as Where-Object. One thing you can do is use the -Filter parameter with logical operators such as -and and -or:
Get-ADUser -filter {(name -lt 'E') -or (name -gt 'G')} |
Select-Object -ExpandProperty Name
this example requires the free RSAT tools from Microsoft to be installed)
PowerShell 技能连载 - Getting AD Users with Selected First Letters
http://blog.vichamp.com/2018/10/12/getting-ad-users-with-selected-first-letters/