Looking for a way to compare a computer account list in an ‘OnPrem’ AD and an ‘AzureAD’ list and list out the differences.
Basically I need something that will allow me to tell which computer accounts on are on the AzureAD list and not on the ‘OnPrem’ AD list.
I’ve done some digging on it and the answer I came up with was useless (Dump both lists to a CSV file and run a compare off of that) as the difference listed all had a trailing $ character on them from AzureAD.
You are correct that you have to dump a list, but it does not have to written to the drive as a CSV.
Just dump the list to two different variables, then use the Compare-Object to compare the data in the two variables.
You can do this dynamically vs files, unless for whatever reason, you need to right the final output to a file.
Do you use the same code for both sides to get the information? The SamAccountName of a computer in AD has a trailing ‘$’. You might compare the name from one side with the SamAccountName from the other side.