Check if the user is a member of a list of AD groups
问题 $groups = 'group1', 'group2'.... I need to check if the user is in a specific AD group and echo the group name if he is not ; can I do it in the pipeline? I have googled a lot and cannot find anything, maybe I am too bad at Google search in English :). $groups | Get-QADGroupMember | Get-QADUser -SamAccountName 'lalala' | ForEach-Object { if ($_.SamAccountName -ne $null) { Write-Host "ok" } else { Write-Host 'not ok' } } How can I display: not ok. user is not in group_name ? 回答1: The question