Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell - list local users and their groups

I'd like to have a report with all the local users and their relative groups (users, power users, administrators and so on.

I get the users in this way:

$adsi = [ADSI]"WinNT://." $adsi.psbase.children | where {$_.psbase.schemaClassName -match "user"} | select @{n="Name";e={$_.name}} 

but I don't know how to retrieve their groups. Thanks in advance.

like image 568
Nicola Cossu Avatar asked Dec 28 '10 18:12

Nicola Cossu


People also ask

How do I list local users in PowerShell?

Use Get-LocalUser PowerShell cmdlet to List All User Accounts. The Get-LocalUser PowerShell cmdlet lists all the local users on a device.

How do I find local groups and users?

Hit the Windows Key + R button combination on your keyboard. Type in lusrmgr. msc and hit Enter. It will open the Local Users and Groups window.

How do I get a list of user group members in PowerShell?

Use Get-ADGroupMember cmdlet to List Members of an Active Directory Group. The PowerShell Get-ADGroupMember cmdlet is used to list the members of an Active Directory group. You can just type the cmdlet in a PowerShell window and you'll be prompted to enter the name of the group you want to use.

How do I get group details in PowerShell?

Use the Get-Group cmdlet to view existing group objects in your organization. This cmdlet returns security groups, mail-enabled security groups, distribution groups, and role groups. For information about the parameter sets in the Syntax section below, see Exchange cmdlet syntax.


1 Answers

For Googlers, another way to get a list of users is to use:

Get-WmiObject -Class Win32_UserAccount 

From http://buckeyejeeps.com/blog/?p=764

like image 60
mjswensen Avatar answered Sep 18 '22 13:09

mjswensen