Closed rcarboneras closed 6 years ago
Hi @rcarboneras !
I encountered the same behaviour and documented issue #45 then created PR #47. As you can see @PaulHigin suggested some modifications I had no time to do...
Your method seems smarter than mine (simpler) ! So I think about canceling my PR to let yours correct the issue.
The main problem we have here is the lack of Unit Test, do you have created some tests for your fix ?
Thanks @jnury for your comment! , I hadn't seen your PR. I have a little environmet of 3 DCs to test with so not much. Either way the proposed change is not a mayor change and I don't see how could affect negatively to the execution of the rest of the code. It only changes de order of the keys but you still have the same keys/values.
Updated ComplexObjectsEqual Method. This method compares two JSON strings that are the result of a ConvertTo-Json from two hashtables. When these hashtables have more than one key (in case you are using more than one role defition) this could fail if order is not maintained.
This example shows the objects compared when this happens. In this case the method returns a false:
[DCTEST]: [DBG]: [Process:1916]: [Runspace3]: PS C:\Windows\system32>> ConvertTo-Json ($this.ConvertStringToHashtable($currentInstance.RoleDefinitions)) -Depth 100 { "GOCGROUP": { "RoleCapabilities": "JeaCompanyDC_GOC" }, "ADMDGroup": { "RoleCapabilities": "JEA_CompanyDC_ADMD" } }
[DCTEST]: [DBG]: [Process:1916]: [Runspace3]: PS C:\Windows\system32>> ConvertTo-Json ($roleDefinitionsHash) -Depth 100 { "ADMDGroup": { "RoleCapabilities": "JEA_CompanyDC_ADMD" }, "GOCGROUP": { "RoleCapabilities": "JeaCompanyDC_GOC" } }
Converting the hashtables into [System.Collections.Specialized.OrderedDictionary] objetcs before converting them to JSON strings, solves the problem.
This change is