From 8a896fc940be2fc26f9b030c587d8abb9ba96b65 Mon Sep 17 00:00:00 2001 From: Will Mellon Date: Wed, 15 Mar 2023 13:31:30 -0400 Subject: [PATCH] Added 'list-local-groups-and-users.ps1' --- list-local-groups-and-users.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 list-local-groups-and-users.ps1 diff --git a/list-local-groups-and-users.ps1 b/list-local-groups-and-users.ps1 new file mode 100644 index 0000000..c468471 --- /dev/null +++ b/list-local-groups-and-users.ps1 @@ -0,0 +1,11 @@ +$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 \ No newline at end of file