You may consider using below command in AD powershell
Get-ADUser -Filter {department -like '9999*' -or samaccountname -eq 'john.abc1' -or samaccountname -eq 'tom.123'} | Where { $_.Enabled -eq $True} | Select DisplayName,Userprincipalname,title,Office,description,co,DepartmentNumber,employeeNumber | Export-csv C:\test\groupmember.csv -Notypeinformation
In addition, Azure Active Directory (Azure AD) now provides the means to validate dynamic group rules (in public preview). On the Validate rules tab, you can validate your dynamic rule against sample group members to confirm the rule is working as expected. When creating or updating dynamic group rules, administrators want to know whether a user or a device will be a member of the group. This helps evaluate whether user or device meets the rule criteria and aid in troubleshooting when membership is not expected.
Detailed steps here: Validate a dynamic group membership rule (preview) in Azure Active Directory
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.