Public/Test-ADSIUserIsGroupMember.ps1

function Test-ADSIUserIsGroupMember
{
<#
.SYNOPSIS
    This function will check if a domain user is member of a domain group
 
.EXAMPLE
    Test-ADSIUserIsGroupMember -GroupSamAccountName TestGroup -UserSamAccountName Fxcat
 
    This will return $true or $false depending if the user Fxcat is member of TestGroup
     
.NOTES
    Francois-Xavier Cat
    LazyWinAdmin.com
    @lazywinadm
#>

    PARAM (
        $GroupSamAccountName,
        
        $UserSamAccountName
    )
    
    $UserInfo = [ADSI]"$((Get-ADSIUser -SamAccountName $UserSamAccountName).AdsPath)"
    $GroupInfo = [ADSI]"$((Get-ADSIGroup -SamAccountName $GroupSamAccountName).AdsPath)"
    
    #([ADSI]$GroupInfo.ADsPath).IsMember([ADSI]($UserInfo.AdsPath))
    $GroupInfo.IsMember($UserInfo.ADsPath)
    
}