misc-powershell-scripts/list-local-groups-and-users.ps1

11 lines
No EOL
431 B
PowerShell

$FormatEnumerationLimit=-1
$grouplist = get-localgroup
$array = @()
foreach ($G in $grouplist){ `
$line = new-object psobject; `
$line | add-member -membertype noteproperty -Name 'Group Name' -Value $G.Name; `
$user = get-localgroupmember -name $G.Name | Select-Object -Property Name; `
$line | add-member -membertype noteproperty -Name 'User' -Value $user.Name; `
$array += $line`
}
$array | ft -wrap -autosize