Files
Powershell-Scripts/Get Scripts/Get Local Computer Users & Groups.ps1
T

10 lines
451 B
PowerShell
Raw Normal View History

2025-08-05 15:07:26 +00:00
Get-LocalUser |
ForEach-Object {
$user = $_
return [PSCustomObject]@{
"Computer-Name" = hostname
"User" = $user.Name
"Groups" = Get-LocalGroup -ErrorAction SilentlyContinue | Where-Object { $user.SID -in ($_ | Get-LocalGroupMember -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SID") } | Select-Object -ExpandProperty "Name"
"Enabled" = $user.Enabled
}
}