Get LocalGroupMember - PowerShell


Overview

Get-LocalGroupMember retrieves a list of users or groups that are members of a specified local group on a Windows computer. It is particularly useful for managing group membership, auditing access permissions, and troubleshooting issues related to user or group permissions.

Syntax

Get-LocalGroupMember [-Group] <String> [[-SID] <System.Security.Principal.SecurityIdentifier>] [-RID] <Int32>

Options/Flags

  • -Group: Specifies the name of the local group whose members you want to retrieve. This argument is mandatory.
  • -SID: Retrieves the member by its Security Identifier (SID).
  • -RID: Retrieves the member by its Relative Identifier (RID).

Examples

Example 1: Retrieve members of a local group

Get-LocalGroupMember -Group "Administrators"

Example 2: Retrieve members of a group by SID or RID

Get-LocalGroupMember -Group "Administrators" -SID "S-1-5-32-544"
Get-LocalGroupMember -Group "Administrators" -RID 544

Common Issues

  • Group not found: Ensure that the specified group exists on the local computer.
  • Access denied: Verify that you have sufficient permissions to retrieve group membership information.

Integration

Get-LocalGroupMember can be combined with other PowerShell commands to perform advanced tasks:

  • Use Where-Object to filter the list of members based on specific criteria:
Get-LocalGroupMember -Group "Users" | Where-Object {$_.Name -like "John*"}
  • Use Add-LocalGroupMember or Remove-LocalGroupMember to manage group membership:
Add-LocalGroupMember -Group "Administrators" -Member "John"
Remove-LocalGroupMember -Group "Users" -Member "Jane"
  • Get-LocalGroup: Retrieves information about local groups and their properties.
  • New-LocalGroup: Creates a new local group on the computer.
  • Remove-LocalGroup: Deletes a local group from the computer.