Get-LocalGroupMember -Group Administrators bug
See original GitHub issuewe stumbled on the following bug.
I think there is the problem, that a non existing SID is in this group, and it cannot be skipped.
PS C:\Windows\system32> Get-LocalGroupMember -Group Administrators
Get-LocalGroupMember : Failed to compare two elements in the array.
At line:1 char:1
-
Get-LocalGroupMember -Group Administrators
-
+ CategoryInfo : NotSpecified: (:) [Get-LocalGroupMember], InvalidOperationException + FullyQualifiedErrorId : An unspecified error occurred.,Microsoft.PowerShell.Commands.GetLocalGroupMemberCommand
PS C:\Windows\system32> $error[0] | fl * -force
writeErrorStream : True
PSMessageDetails :
Exception : System.InvalidOperationException: Failed to compare two elements in the array. —> System.NullReferenceException: Object reference not set to an
instance of an object.
at Microsoft.PowerShell.Commands.GetLocalGroupMemberCommand.<>c.<ProcessesMembership>b__20_0(LocalPrincipal p1, LocalPrincipal p2)
at System.Collections.Generic.ArraySortHelper`1.SwapIfGreater(T[] keys, IComparer`1 comparer, Int32 a, Int32 b)
at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
--- End of inner exception stack trace ---
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer)
at System.Collections.Generic.List`1.Sort(Comparison`1 comparison)
at Microsoft.PowerShell.Commands.GetLocalGroupMemberCommand.ProcessesMembership(IEnumerable`1 membership)
at Microsoft.PowerShell.Commands.GetLocalGroupMemberCommand.ProcessRecord()
TargetObject :
CategoryInfo : NotSpecified: (😃 [Get-LocalGroupMember], InvalidOperationException
FullyQualifiedErrorId : An unspecified error occurred.,Microsoft.PowerShell.Commands.GetLocalGroupMemberCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Related StackOverflow Question
Script for cleaning up, so that you can continue.
Currently we have WCP in the project and we can enable on Windows cmdlets and feature that were turned off due to lack of APIs in .Net Core.
You can look
DefaultCommands.Tests.ps1. (In csproj files you can seeCompile Remove=. In cs file you can seeif UNIXorif !Unix.)Report on UserVoice and link the post in Issue in the repo. I think with the advent of WCP inactive code will become much less.