- # 2>nul&@cls&@echo off&powershell -command "&{set-executionPolicy remoteSigned}"© "%~f0" "%~f0.ps1">nul&powershell -file "%~f0.ps1"&del "%~f0.ps1"&pause&exit /b 0
- $file1 = GI C:\TEMP\schlecht\Settings.xml;
- $file2 = GI C:\TEMP\gut\Settings.xml;
- function Compare-Files{
- param(
- $file1,
- $file2,
- [switch]$IncludeEqual
- )
- $content1 = Get-Content $file1;
- $content2 = Get-Content $file2;
- $comparedLines = Compare-Object $content1 $content2 -IncludeEqual:$IncludeEqual | group { $_.InputObject.ReadCount } | sort Name;
- $comparedLines | foreach {
- $curr=$_
- switch ($_.Group[0].SideIndicator){
- "==" { $right=$left = $curr.Group[0].InputObject;break}
- "=>" { $right,$left = $curr.Group[0].InputObject,$curr.Group[1].InputObject;break }
- "<=" { $right,$left = $curr.Group[1].InputObject,$curr.Group[0].InputObject;break }
- }
- [PSCustomObject] @{
- Line = $_.Name;
- Left = $left;
- Right = $right;
- }
- }
- }
- Compare-Files -file1 $file1 -file2 $file2 -IncludeEqual;
复制代码 bat 和powershell均通过。程序是对的,是不是你的策略设置有问题。 |