Hello,
I want to see only enabled users from administrator group on windows 10 device. Get-LocalGroupMember Administrators command is not supported in some powershell modules. Anyone have any other ideas?
Thank you
Hello,
I want to see only enabled users from administrator group on windows 10 device. Get-LocalGroupMember Administrators command is not supported in some powershell modules. Anyone have any other ideas?
Thank you
As answered on one of your several duplicated posts across the web.
$enabledlocal = Get-WmiObject win32_useraccount | Where-Object {$_.Disabled -eq $false}
$adminmembers = Get-WmiObject win32_groupuser | Where-Object {$_.groupcomponent -like '*administrators*'}
$adminmembers.partcomponent -replace '^.+Name="|"$' | Where-Object {$_ -in $enabledlocal.Name}
Or you could flip it to
$enabledlocal | Where-Object {$_.Name -in @($adminmembers.partcomponent -replace '^.+Name="|"$')
it’s working. thank you