I have an xml file to read in to ad.The hard part is that what is stated in the xml file is what applies.First, it must be checked that no countries other than Norway and Sweden are updated.No problem with that.But in ad it can say that a certain user belongs to Sweden but in the xml file it says for example.Finland and then it is the one in the xml file that should apply and it should not be updated and it is this particular control i have problems with.Anyone have an idea?
Now I have don'e that control something like this. And I can't get this to work.
Please format your code as code by using the code (pre) tag button provided on the edit bar of the post editor. Thanks.
Are you sure Compare-Object works the way you expect it? If you only need the equal elements from both objects you can add the parameter -ExcludeDifferent. Additionally you could add -PassThru to get the input object as output as well.
I still can’t get this to work. It shows me either <= or => as sideindicator if I want to select == it wount work even if the country are like in file and in ad then it just show nothing.
And this is the problem it shall only get info that are alike == nothing else. If ther are difference between file and ad in country then it shall not show that at all.
Is there a special reason why you are using XML formatted data? Most people would choose CSV for structured data and for comparison. Espcially because the code line you commented with #Importing AD Users creates a structured data set from the AD.
Instead of using an if clause to compare if the side indicator is the desired one, have you tried piping it through Where-Object instead?
I ran into this issue with a script I wrote at work, and I don’t have access to our private github right now, but it I remember on Monday I’ll check the code.
However, I seem to remember that Where-Object was the thing that finally worked for me. Trying to use comparison operators and if clauses on special charectors like the side indicator would not return $True even when you expect it to, but Where-Object did work.