I have a AD group "xyz" having 1500 members in it. I want to select initial 200 users and send emails to them.
I am not sure how to filter the 200 users from the group using PowerShell code,i have all members list but want to know how can I filter 200 users from it?
please help
>Solution :
You can abort a pipeline after receiving X input objects with Select-Object -First X:
Get-ADGroupMember xyz |Select-Object -First 200
If you want a random sample, use Get-Random -Count:
Get-ADGroupMember xyz |Get-Random -Count 200
Beware that Active Directory doesn’t guarantee any specific sort order, so you’ll have to manually keep track of which users you’ve already processed (if you want to only process each member once for example)