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.
Use Get-LocalUser PowerShell cmdlet to List All User Accounts. The Get-LocalUser PowerShell cmdlet lists all the local users on a device.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With