Hi,
The PowerShell AD module has to be installed first.
https://4sysops.com/wiki/how-to-install-the-powershell-active-directory-module/
Then you check the user like this
$username = 'user1'
$group = 'group1'
$user = Get-ADGroupMember -Identity $group | Where-Object {$_.name -eq $username}
if($user){
Write-Host 'member found'
}
else{
Write-Host 'member not found'
}
Best Regards,
Ian Xue
============================================
If the 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.