Here is another quick PowerShell script to check if user is a member of given group.
[cc lang=”PowerShell”]
Clear-Host
if (Get-Module -ListAvailable -Name ActiveDirectory) {
Import-Module ActiveDirectory
} else {
”
Write-Host “Operation aborted. No Active Directory Module found. Run this tool on a Domain Controller.” -ForegroundColor Red
”
throw “Error”
}
Write-Host “CHECK IF USER IS MEMBER OF THE GROUP” -ForegroundColor white -BackgroundColor Red
Write-Host
$user = Read-Host [=> “Enter User Name”
$group = Read-Host [=> “Enter Group Name”
$members = Get-ADGroupMember -Identity $group -Recursive | Select -ExpandProperty Name
If ($members -contains $user) {
Write-Host “$user exists in the group”
} Else {
Write-Host “$user does not exist in the group”
}
[/cc]
Another quick idea , please test before you try in live environment ..
