Remove a machine local security group.
Syntax
Remove-LocalGroup { [-InputObject] LocalGroup | [-Name] String[] | [-SID] SecurityIdentifier[] }
[-Confirm] [-WhatIf] [CommonParameters]
Key
-InputObject
Specifies an array of security groups that this cmdlet deletes.
To obtain groups, use the Get-LocalGroup cmdlet.
-Name
An array of security group names to delete.
-SID
An array of security group IDs (SIDs) to delete.
-Confirm
Prompt for confirmation before executing the command.
-WhatIf
Describe what would happen if you executed the command without actually executing it.
The Remove-LocalGroup cmdlet deletes local security groups. This cmdlet deletes only a local group. It does not delete the user accounts, computer accounts, or group accounts that belong to that group. You cannot recover a deleted group.
If you delete a group and then create another group that has the same group name, you must set new permissions for the new group. The new group will not inherit any permissions that were assigned to the old group.
Standard Aliases for Remove-LocalGroup: rlg
This cmdlet cannot delete the following default groups:
Administrators,
Backup Operators,
Cryptographic Operators,
Distributed COM Users,
Event Log Readers,
Guests,
Hyper-V Administrators,
IIS_IUSRS,
Network Configuration Operators,
Performance Log Users,
Performance Monitor Users,
Power Users,
Remote Desktop Users,
Remote Management Users,
Replicator,
Users,
WinRMRemoteWMIUsers__
The PrincipalSource property is a property on LocalUser, LocalGroup, and LocalPrincipal objects that describes the source of the object. The possible sources are as follows: Local, Active Directory, Microsoft Entra group, Microsoft Account.
Delete a security group:
PS C:\> Remove-LocalGroup -Name "local64"
“Somehow people always forget that it's much easier to install a dictator than to remove one” ~ Garry Kasparov
Get-LocalGroup - Get the local security groups.
New-LocalGroup - Add a new local security group.
Rename-LocalGroup - Rename a local security group.
Set-LocalGroup - Change a local security group.
Remove-adGroup - Remove an AD group.