Skip to content

Instantly share code, notes, and snippets.

@santisq
Created April 28, 2022 03:02
Show Gist options
  • Select an option

  • Save santisq/1d8461a2d0baa9ed6ac40fe77f8f7da0 to your computer and use it in GitHub Desktop.

Select an option

Save santisq/1d8461a2d0baa9ed6ac40fe77f8f7da0 to your computer and use it in GitHub Desktop.
Get-CimInstance Win32_UserAccount | ForEach-Object {
$membership = Get-CimAssociatedInstance $_ -ResultClassName Win32_Group
[pscustomobject]@{
Computername = $Env:COMPUTERNAME
UserName = $_.Name
Memberof = $membership.Name -join ';'
Status = $membership.Name -contains 'Administrators'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment