0

Is there easy way to get all users from all local groups. I mean that I need to get users from all groups, because sometimes we have standard list of local groups and sometimes someone create additional users like for DHCP or other applications and the add ther specific users. But my think is to get list of users from Administrators, Users, RDP Users etc.

Is any easy way to get it?

  • 3
    [Get-LocalGroup](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/get-localgroup?view=powershell-5.1) ... [Get-LocalGroupMember](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/get-localgroupmember?view=powershell-5.1) ... it would have taken you about 30 seconds of googling to figure that out by yourself ;-) – Olaf Oct 21 '21 at 19:06
  • 1
    Does this answer your question? [powershell - list local users and their groups](https://stackoverflow.com/questions/4548476/powershell-list-local-users-and-their-groups) – spicy.dll Oct 21 '21 at 20:40

1 Answers1

0

I haven't tested this since I'm not near a Windows computer, but something like this should work:

$groups = Get-LocalGroup
foreach ($g in $groups.Name){
    Get-LocalGroupMember $g
}
FuegoJohnson
  • 372
  • 6
  • 18