Remove-GroupMember

Removes users or groups from a local group.

Syntax

Remove-GroupMember [-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-GroupMember is new in Carbon 2.0.

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The group name.

true false
Member String[]

The users/groups to remove from a group.

true false
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

EXAMPLE 1

Remove-GroupMember -Name Administrators -Member EMPIRE\DarthVader,EMPIRE\EmperorPalpatine,REBELS\LSkywalker

Removes Darth Vader, Emperor Palpatine and Luke Skywalker from the local administrators group.

EXAMPLE 2

Remove-GroupMember -Name TieFighters -Member NetworkService

Removes the local NetworkService account from the local TieFighters group.