Get-LocalGroupMember - Failed to compare two elements in the array.

See original GitHub issue

It appears that if you have domain groups added to a local group and then move the server to a workgroup before removing them Get-LocalGroupMember no longer works and instead throws an exception ‘Failed to compare two elements in the array.’. I am seeing this on Server 2016 Core, I have not tried on any other editions. I found this while building a server in one domain that needed to move to a different one.

Steps to reproduce

  • Join a Windows Server 2016 Core server to a domain.
  • Added 3 domain groups to the local administrators group.
  • Moved the server back into a workgroup.
  • Ran Get-LocalGroupMember -Group Administrators

I’ve reproduced this on two servers.

Expected behavior

It should return the group members as it would prior to moving to a workgroup and just display the unresolved SIDs for the old domain. Then ideally allow you to reference those unresolved SIDS for Remove-LocalGroupMember.

Actual behavior

Throws an exception. 2017-01-11_17-32-25

Environment data

> $PSVersionTable
PSVersion                      5.1.14393.206
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.206
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:15
  • Comments:141 (23 by maintainers)

github_iconTop GitHub Comments

15reactions
mjr4077aucommented, Feb 3, 2022

This really needs to be re-opened. The issue may be caused by orphaned SIDs, but the orphaned SIDs on my device are AzureAD SIDs. I don’t want to resort to the ADSI interface because while I understand it, my colleagues probably wouldn’t. We use Powershell to use its native modules and cmdlets…

13reactions
SteveL-MSFTcommented, Nov 28, 2017

@Hicsy after we have a fix in PSCore6, we can consider backporting it to Windows PowerShell 5.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get-LocalGroupMember generates error for Administrators ...
PS C:\WINDOWS\system32> Get-LocalGroupMember -Group "Administrators" Get-LocalGroupMember : Failed to compare two elements in the array.
Read more >
Get-LocalGroupMember : Failed to compare two elements in ...
I received an error that something was wrong with the command. Get-LocalGroupMember : Failed to compare two elements in the array. At line:1 ......
Read more >
get-localgroupmember Workaround : r/PowerShell
Get -LocalGroupMember : Failed to compare two elements in the array. At line:1 char:1 + Get-LocalGroupMember -Group "Administrators"
Read more >
Public/Get-LocalGroupUsers.ps1 0.2.1
#There is a known issue, in some situation Get-LocalGroupMember return: Failed to compare two elements in the array. $contents = Get-LocalGroupMember -group ...
Read more >
Failed to compare two elements in the array
I was getting the error because the property in the sort description was blank. Once I fixed this everything worked fine without the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found