< Back

Test-CGroupMember

Sun Jan 12, 2020 11:23 pm

NAME Test-CGroupMember



SYNOPSIS

Tests if a user or group is a member of a *local* group.





SYNTAX

Test-CGroupMember [-GroupName] <String> [-Member] <String> [<CommonParameters>]





DESCRIPTION

The `Test-CGroupMember` function tests if a user or group is a member of a *local* group using [.NET's

DirectoryServices.AccountManagement

APIs](https://msdn.microsoft.com/en-us/librar ... ement.aspx). If the group or

member you want to check don't exist, you'll get errors and `$null` will be returned. If `Member` is in the group,

`$true` is returned. If `Member` is not in the group, `$false` is returned.



The user running this function must have permission to access whatever directory the `Member` is in and whatever

directory current members of the group are in.



This function was added in Carbon 2.1.0.





PARAMETERS

-GroupName <String>

The name of the group whose membership is being tested.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Member <String>

The name of the member to check.



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Test-CGroupMember -GroupName 'SithLords' -Member 'REBELS\\LSkywalker'



Demonstrates how to test if a user is a member of a group. In this case, it tests if `REBELS\\LSkywalker` is in the

local `SithLords`, *which obviously he isn't*, so `$false` is returned.











RELATED LINKS

Add-CGroupMember

Install-CGroup

Remove-CGroupMember

Test-CGroup

Uninstall-CGroup