These two files are clearly different. But Compare-Object
finds no difference. The first file has a Unicode BOM. Is there any way to get Compare-Object
to identify that they are different?
PS C:\Temp> dir file*
Directory: C:\Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2021-06-01 14:38 163673 file1.txt
-a--- 2021-03-18 17:08 163670 file2.txt
PS C:\Temp> Compare-Object -ReferenceObject (Get-Content -Path .\file2.txt) -DifferenceObject (Get-Content -Path .\file2.txt)
PS C:\Temp> Format-Hex -Path .\file1.txt | Select-Object -First 1
Label: C:\Temp\file1.txt
Offset Bytes Ascii
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
------ ----------------------------------------------- -----
0000000000000000 ***EF BB BF*** 3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E <?xml version
PS C:\Temp> Format-Hex -Path .\file2.txt | Select-Object -First 1
Label: C:\Temp\file2.txt
Offset Bytes Ascii
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
------ ----------------------------------------------- -----
0000000000000000 3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31 <?xml version="1
PS C:\Temp> $PSVersionTable.PSVersion.ToString()
7.1.3