< Back
Remove-CGroupMember
Post
NAME Remove-CGroupMember
SYNOPSIS
Removes users or groups from a *local* group.
SYNTAX
Remove-CGroupMember [-Name] <String> [-Member] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
You would think it's pretty easy and straight-forward to remove users/groups from a local group, but you would be
wrong. The quick solution is to use `net localgroup`, but that won't accept user/group names longer than 24
characters. This means you have to use the .NET Directory Services APIs. How do you reliably remove both users
*and* groups? What if those users are in a domain? What if they're in another domain? What about built-in
users? Fortunately, your brain hasn't exploded.
So, this function removes users or groups from a *local* group.
If the user or group is not a member, nothing happens.
`Remove-CGroupMember` is new in Carbon 2.0.
PARAMETERS
-Name <String>
The group name.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Member <String[]>
The users/groups to remove from a group.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Required? false
Position? named
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:\\>Remove-CGroupMember -Name Administrators -Member EMPIRE\\DarthVader,EMPIRE\\EmperorPalpatine,REBELS\\LSkywalker
Removes Darth Vader, Emperor Palpatine and Luke Skywalker from the local administrators group.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Remove-CGroupMember -Name TieFighters -Member NetworkService
Removes the local NetworkService account from the local TieFighters group.
RELATED LINKS
SYNOPSIS
Removes users or groups from a *local* group.
SYNTAX
Remove-CGroupMember [-Name] <String> [-Member] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
You would think it's pretty easy and straight-forward to remove users/groups from a local group, but you would be
wrong. The quick solution is to use `net localgroup`, but that won't accept user/group names longer than 24
characters. This means you have to use the .NET Directory Services APIs. How do you reliably remove both users
*and* groups? What if those users are in a domain? What if they're in another domain? What about built-in
users? Fortunately, your brain hasn't exploded.
So, this function removes users or groups from a *local* group.
If the user or group is not a member, nothing happens.
`Remove-CGroupMember` is new in Carbon 2.0.
PARAMETERS
-Name <String>
The group name.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Member <String[]>
The users/groups to remove from a group.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Required? false
Position? named
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:\\>Remove-CGroupMember -Name Administrators -Member EMPIRE\\DarthVader,EMPIRE\\EmperorPalpatine,REBELS\\LSkywalker
Removes Darth Vader, Emperor Palpatine and Luke Skywalker from the local administrators group.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Remove-CGroupMember -Name TieFighters -Member NetworkService
Removes the local NetworkService account from the local TieFighters group.
RELATED LINKS