powershell 获得会员

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 获得会员相关的知识,希望对你有一定的参考价值。

function Get-ADPrincipalGroupMembershipRecursive( ) {

    Param(
        [string] $dsn,
        [array]$groups = @()
    )

    $obj = Get-ADObject $dsn -Properties memberOf

    foreach( $groupDsn in $obj.memberOf ) {

        $tmpGrp = Get-ADObject $groupDsn -Properties memberOf

        if( ($groups | Where-Object { $_.DistinguishedName -eq $groupDsn }).Count -eq 0 ) {
            $groups +=  $tmpGrp           
            $groups = Get-ADPrincipalGroupMembershipRecursive $groupDsn $groups
        }
    }

    return $groups
}

function Get-Member() {

    param (
        [string] $username,
        [string] $groupname
    )

    # Get the AD groups the user is member of
    $groups = Get-ADPrincipalGroupMembershipRecursive -dsn (Get-ADUser $username).DistinguishedName

    if ($groups.Name -contains $groupname) {
        # user is member of the group
        return $true
    }
    else {
        return $false
    }


}


# Get the username of the current logged on user
#$username = $env:USERNAME
$username = 'a9316143'
$groupname = 'GAP_VA_OpCon'

Get-Member -username $username -group $groupname

以上是关于powershell 获得会员的主要内容,如果未能解决你的问题,请参考以下文章

樊登读书会怎么免费获得会员

如何获得在线会员数量?

Powershell 获得备用许可证

powershell 获得免费的车道信

powershell 广告获得的GPO

使用 powershell 获得计数器性能